惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
S
Schneier on Security
人人都是产品经理
人人都是产品经理
博客园_首页
L
LangChain Blog
D
Docker
B
Blog
阮一峰的网络日志
阮一峰的网络日志
D
DataBreaches.Net
C
Check Point Blog
WordPress大学
WordPress大学
博客园 - 聂微东
P
Palo Alto Networks Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
腾讯CDC
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
Help Net Security
Help Net Security
The Last Watchdog
The Last Watchdog
有赞技术团队
有赞技术团队
美团技术团队
aimingoo的专栏
aimingoo的专栏
博客园 - 叶小钗
爱范儿
爱范儿
S
Security @ Cisco Blogs
MyScale Blog
MyScale Blog
C
Cisco Blogs
P
Proofpoint News Feed
I
Intezer
Last Week in AI
Last Week in AI
The Register - Security
The Register - Security
IT之家
IT之家
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
H
Help Net Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Latest news
Latest news
M
MIT News - Artificial intelligence
N
News | PayPal Newsroom
G
Google Developers Blog
Cloudbric
Cloudbric
T
Troy Hunt's Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Recorded Future
Recorded Future
Hugging Face - Blog
Hugging Face - Blog
AWS News Blog
AWS News Blog

博客园 - YCOE

MongoDB异常关闭引起的CPU占用 linux php 安装openssl备忘 yum Segmentation fault 错误处理 storytlr -- 安装体验 FullCalendar的二次开发、扩展 记一次笔记本CPU性能骤降 [原创]狂想--QQ构架 [原创]基于jquery.Jcrop的头像编辑器 [原创][C#] 如何将String类型转换成任意基本类型 [原创]Annotation之ElementType.PACKAGE 短信切割算法 C# Unrecognized configuration section system.serviceModel 发现Google浏览器(Chrome)的一个JavaScript Bug DWR死锁问题解决 [原创]DWR+OSGi整合v2.0 [原创]DWR与OSGi的整合 [转载]使用java.text包格式化数字和日期 Hibernate merge方法 MySQL数据库使用Innodb数据库类型(工具生成Hibernate+Spring代码)
Log4net的使用
YCOE · 2008-11-19 · via 博客园 - YCOE

用惯了Log4j,现在用到Log4net还真要整上一阵子,总的来说,没有Java下面这么方便.

在Java环境中,只要放一个log4j配置文件,使用默认的文件名,Log4j就会自己去读取,但是在.net 环境下,竟要自己指定Log4net去读取

尝试了会,记录下来,备忘.

Log4net的配置步骤如下:

1. 引用Log4net.dll(http://logging.apache.org/log4net/index.html)

2. 写配置文件,如果发懒,也可以直接拷下面的,再修改

Log4net.config(放置在项目最上层,别忘了设置每次修改都复制到生成目录下)

Code

详细的配置说明这里不作解释,可以到以下官方了解:http://logging.apache.org/log4net/release/config-examples.html

3. 在项目启动文件中(例如AssemblyInfo.cs)里添加以下代码

Code

4. 代码中使用,

     引入:using log4net;

     定义:private static readonly ILog logger = LogManager.GetLogger(typeof(类名));

     使用:logger.***,就这样,不说啦!