开发环境:win7+vs2010+VB.net+.net4.0
1.下载log4net (http://logging.apache.org/log4net/)
2.新建类库类项目
3.添加log4net.dll
4.添加新项log4net的XML配置文件,例如起名为:OracleLog4Helper.config,编写内容如下:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- Register a section handler for the log4net section -->
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
</configSections>
<log4net>
<!-- the rollingFile Appender, which could save log to File ,and according to the configuration, when the file reach 100kb, it will save the old file to the TestLog4Net.log.1, and the TestLog4Net.log.2 and that's all-->
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="OracleLog4Helper.Log" />

本文介绍了如何在VB.NET类库项目中集成log4net实现日志记录,通过XML配置文件设置rollingFile Appender,将日志保存到文件,并在代码中创建日志对象进行日志写入。
1万+

被折叠的 条评论
为什么被折叠?



