Difference between revisions of "Log4net"

From Richard's Wiki
Jump to: navigation, search
(New page: * [http://geekswithblogs.net/bsherwin/archive/2008/02/15/119657.aspx Moving your Log4Net configuration out of web.config with ASP.NET 2.0 web sites] AssemblyInfo.cs: [assembly: log4net.Co...)
 
 
Line 1: Line 1:
 +
* Declare a Logger without explicitly naming the calling type (use reflection):
 +
 +
using System.Reflection;
 +
private readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 +
 
* [http://geekswithblogs.net/bsherwin/archive/2008/02/15/119657.aspx Moving your Log4Net configuration out of web.config with ASP.NET 2.0 web sites] AssemblyInfo.cs:
 
* [http://geekswithblogs.net/bsherwin/archive/2008/02/15/119657.aspx Moving your Log4Net configuration out of web.config with ASP.NET 2.0 web sites] AssemblyInfo.cs:
 
  [assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
 
  [assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]

Latest revision as of 21:21, 14 September 2011

  • Declare a Logger without explicitly naming the calling type (use reflection):
using System.Reflection;
private readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]