log4net is reporting:
No appenders could be found for logger log4net: Logger: Please initialize the log4net system properly.
I have a stand alone log4net config file:
<!--?xml version="1.0"?-->
<configuration>
<configsections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" />
</configsections>
<log4net>
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="c:\temp\log.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="5MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>
</configuration>
..and this app start code
private static ILog logger;
protected void Application_Start(object sender, EventArgs e)
{
////This tells log4net where to go and look for its configuration file and also to watch it for any changes
log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(@"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\Config\Moogle\Log4Net.config"));
logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
logger.Debug("Application_Start Fired");
The log4net configuration can be configured using assembly-level attributes rather than specified programmatically. If specified, this is the filename of the configuration file to use with the XmlConfigurator. This file path is relative to the application base directory (AppDomain. CurrentDomain.
Log4j is a very popular logging framework for Java developers, used by most Java applications. It has been ported to other programming languages including log4perl, log4php, log4net, and log4r.
You can configure the log4net. config file to create log files. The file is located in the webroot\App_data directory of the installation.
You have only defined an appender. You also need to define a root logger and a logger to use the appender (they can be the same logger if you only need one). Add the following root element below to your log4net config.
<root>
<level value="DEBUG" />
<appender-ref ref="RollingLogFileAppender" />
</root>
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