logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: Problem getting Log4net to work
Date Tue, 13 May 2008 04:30:52 GMT
What does log4net's internal debug message say:

 http://logging.apache.org/log4net/release/faq.html

Have you tried configuring log4net from within the client app's entry point to verify your
log4net.config is correct?

----- Original Message ----
From: Neil Haughton <Neil.Haughton@autoscribe.co.uk>
To: Log4NET User <log4net-user@logging.apache.org>
Sent: Monday, May 12, 2008 11:26:00 AM
Subject: Problem getting Log4net to work

Can anybody spot what I am doing wrong? I'm probably doing something stupid, but I've been
banging my head against this for a few days and am getting no further:

I have a solution comprising two projects, a client app and a logger project. The logger project
encapsulates calls to log4net. It has a line in its AssemblyInfo file

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

and static loggers and methods to call various loggers, eg

       private static readonly ILog bllDebugLog = LogManager.GetLogger("Matrix.Trace"); 

and so on.

a Typical logging method in the logger code is

        public static void Trace(string message)
        {
            using (NDC.Push("TRACE"))
            {
              bllDebugLog.Debug(message);
            }
        }


In the same solution I have an application which references the above assembly. The application
makes calls to the static log methods, eg logger.Trace("a message");

and the log4net.config file is in the executable directory of the application (...\bin\debug
and ...\bin\release).

It all seems straight out of the book, but try as I might I cannot get log4net to log anything!

The bare bones of the log4net.config file is:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <log4net>


        <appender name="RollingFileAppenderROOT" type="log4net.Appender.RollingFileAppender">
            <file value="c:\logs\MatrixROOT.log" />
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%m%newline" />
            </layout>
            <appendToFile value="true" />
            <maximumFileSize value="100KB" />
            <maxSizeRollBackups value="2" />
        </appender>


        <appender name="RollingFileAppenderTRACE" type="log4net.Appender.RollingFileAppender">
            <file value="c:\logs\MatrixTRACE.log" />
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%m%newline" />
            </layout>
            <appendToFile value="true" />
            <maximumFileSize value="100KB" />
            <maxSizeRollBackups value="2" />
        </appender>


        <root>
            <appender-ref ref="RollingFileAppenderROOT" />
        </root>

        <logger name="Matrix.Trace">
             <!--this is for routine debug logging to a file--> 
            <level value="DEBUG" />
            <appender-ref ref="RollingFileAppenderTRACE" />
        </logger>

    </log4net>
</configuration>


TIA

Neil

Mime
View raw message