码迷,mamicode.com
首页 > 移动开发 > 详细

using log4net on my project within a self-hosted WCF application z

时间:2015-04-22 17:33:01      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:

  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");

using log4net on my project within a self-hosted WCF application z

标签:

原文地址:http://www.cnblogs.com/zeroone/p/4447884.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!