I have this code and the config file below:
ILog log = LogManager.GetLogger(typeof(MyClass)); log.Debug("Testing");
TestProj
directory is not created and if I create it, no TestLog.txt
file, no log ... nothing.
Any idea?
Thanks,
The config file
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" /> <log4net debug="true"> <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender"> <file value="C:\\TestProj\\TestLog.txt" /> <appendToFile value="true" /> <rollingStyle value="Size" /> <maxSizeRollBackups value="10" /> <maximumFileSize value="10MB" /> <staticLogFileName value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%-5p %d %5rms %-22.22c{1} %-18.18M - %m%n" /> </layout> </appender> <root> <level value="DEBUG" /> <appender-ref ref="RollingLogFileAppender" /> </root> </log4net>
Add log4net in config file config and enter the following details. Add a class Log. cs in the Utilities folder. Now, in the constructor of this class, instantiate logs for monitoring and debugger loggers.
You need to call the Configure
function of the XmlConfigurator
log4net.Config.XmlConfigurator.Configure();
Either call before your first loggin call or in your Global.asax like this:
protected void Application_Start(Object sender, EventArgs e) { log4net.Config.XmlConfigurator.Configure(); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With