Under my VS2010 solution I’ve this situation:
- WEBSITE
- Library1
- Library2
On global.asax.cs I initialize the log4net configuration using:
private static log4net.ILog _logger = log4net.LogManager.GetLogger("globalASAX");
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
log4net.Config.XmlConfigurator.Configure();
_logger.Info("[APPLICATION START] " + DateTime.Now.ToString());
}
It works fine and Application start message is correclty available on log.txt file. The problem happens when I try to use log something on the classes available on DLL Library1 or Library2.
I added the row:
private static log4net.ILog _logger = log4net.LogManager.GetLogger(typeof(ImageRepository));
but when I try to all the _logger.error(“blabla”) nothing happens on log file; all properties of _logger are false (i.e. isdebugenable=false). How can I fix that? I followed the instruction available here:
http://logging.apache.org/log4net/release/manual/configuration.html
the configuration of log4net is under web.config file:
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString">
<conversionPattern value="log\explorer-log-%date{ yyyy.MM.dd.HH.mm.ss}-[%processid].log"/>
</file>
<appendToFile value="true"/>
<maximumFileSize value="1024KB"/>
<maxSizeRollBackups value="5"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %logger - %message%newline"/>
</layout>
</appender>
<root>
<level value="DEBUG"/>
<appender-ref ref="RollingFile"/>
</root>
</log4net>
anyone can help me?
thanks,
Andrea
I suspect log4net cannot find the logger for your type ImageRepository. As a quick check create a named logger and try calling it.
And config