博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
using log4net on my project within a self-hosted WCF application z
阅读量:6888 次
发布时间:2019-06-27

本文共 931 字,大约阅读时间需要 3 分钟。

  1. Add reference to log4net.dll to our console service host project (our application entry point)
  2. Add the following line to the above project's AssemblyInfo.cs file (allows a custom log4net config file to be specified, which log4net will "watch" for updates. Quick, but maybe a bit dirty..)

    [assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]

  3. // LOG 4 net config
    [assembly:log4net.Config.XmlConfigurator(Watch=true)]
  4. Add log4net.config file to console project and copy it to the output directory (file properties: "Copy to Output Directory")

  5. Add log4net.dll reference to all projects where you require logging
  6. Declare the logger as private static member of the classes where you need logging:

    private static readonly log4net.ILog Logger =  log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
  7. Log where required:
  8. Logger.Info("Starting console service host");

转载地址:http://bqtbl.baihongyu.com/

你可能感兴趣的文章
STL容器底层数据结构的实现
查看>>
Web设计的Ruby on Rails 第2章 变量、数组、散列表
查看>>
关于提升自己
查看>>
python基础
查看>>
权限管理--通用
查看>>
python爬虫爬取赶集网数据
查看>>
微信公众平台开发(系列教程)
查看>>
CentOS中配置Kafka集群
查看>>
Android IOS WebRTC 音视频开发总结(六六)-- 三个角度分析美女视频直播这个行业...
查看>>
ExpandableListView视图树简单应用
查看>>
popwindow
查看>>
多线程 打字练习
查看>>
[BSGS]
查看>>
day19-2 生成器,递归函数
查看>>
未能加载文件或程序集“Enyim.Caching”或它的某一个依赖项。未能验证强名称签名...
查看>>
设计模式——面向对象设计原则
查看>>
mysql安装
查看>>
301、302跳转与200状态码
查看>>
小波变化库——Pywalvets学习笔记
查看>>
y - 1,一个 缝隙,
查看>>