VB.net类库中应用log4net实现日志记录(文件形式)

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

开发环境: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">
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值