Search This Blog

Sunday, November 9, 2014

Adding log4net for asp.net app

add reference to the newest log4net dll

add the configSections right after the configuration section in the web.config

add into the  end of the file AssemblyInfo.cs
[assembly: log4net.Config.XmlConfigurator(Watch = true)]

in the code:
private static readonly ILog log = LogManager.GetLogger(typeof(Myclass));

sources:
http://logging.apache.org/log4net/release/manual/configuration.html


option two:
is too have the config file not in the web.config via
add into the  end of the file AssemblyInfo.cs

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