Monday, May 21, 2012
 
The best way to analyze your logs! Minimize
 Log4Net Mail archive   

The Log4Net mailing list is a great source of information about using log4Net, in this forum we collect all the messages in the log4net user list and some selected threads from the developer list.

Subject: Mystery concerning configuration
Prev Next
You are not authorized to post a reply.

Author Messages
Eric Chamberlain

06/19/2009 12:41 AM  

Greetings all,

 

I have an appender which works fine if specified with generic XML but not when specified with conventional log4net terms in the configuration.

 

Examples should help:

 

The following works:

 

  <appender name="LogServiceAppender"

            type="log4net.Appender.RollingFileAppender">

    <param name="File"

           value="myfile.log" />

    <param name="AppendToFile"

           value="true" />

    <param name="MaxSizeRollBackups"

           value="10"/>

    <param name="MaximumFileSize"

           value="1MB"/>

    <param name="RollingStyle"

           value="Size"/>

    <param name="StaticLogFileName"

           value="true"/>

    <layout type="log4net.Layout.PatternLayout">

      <param name="ConversionPattern"

             value="%d{yyyy MMM dd HH:mm:ss} [%t] %-5p - %m%n" />

    </layout>

  </appender>

 

But the following does *not* work.  It fails to initialize (I turned on the log4net debugging to see it).

 

  <appender name="LogServiceAppender"

            type="log4net.Appender.RollingFileAppender">

    <file value="myfile.log" />

    <appendToFile value="true"/>

    <maxSizeRollBackups value="10"/>

    <maximumFileSize value="1MB"/>

    <rollingStyle value="Size"/>

    <staticLogFileName value="true"/>

    <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%d{yyyy MMM dd HH:mm:ss} [%t] %-5p - %m%n" />

    </layout>

  </appender>

 

It appears that log4net initialization does not recognized its own XML schema.   How is that possible? 

______________________________________________________________________

Eric Chamberlain

Ron Grabowski

06/19/2009 5:22 AM  
WorksOnMyMachine

class Program
{
    static void Main(string[] args)
    {
        LogLog.InternalDebugging = true;
        LogLog.EmitInternalMessages = true;

        XmlDocument log4netConfig = new XmlDocument();
        log4netConfig.LoadXml(@"
            <log4net>
            <appender name='LogServiceAppender' type='log4net.Appender.RollingFileAppender'>
                <file value='c:\\LogServiceAppender.log' />
                <appendToFile value='true'/>
                <maxSizeRollBackups value='10'/>
                <maximumFileSize value='1MB'/>
                <rollingStyle value='Size'/>
                <staticLogFileName value='true'/>
                <layout type='log4net.Layout.PatternLayout'>
                  <conversionPattern value='%d{yyyy MMM dd HH:mm:ss} [%t] %-5p - %m%n' />
                </layout>  
            </appender>
            <root>
                <level value='ALL' />
                <appender-ref ref='LogServiceAppender' />
            </root> 
        </log4net>");

        ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
        XmlConfigurator.Configure(rep, log4netConfig["log4net"]);
        ILog log = LogManager.GetLogger(rep.Name, "Program");
        log.Debug("Hello World");
    }
}

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Mystery concerning configuration



ActiveForums 3.7

 

 

 

 

 

 

 

 

Log4Net Dashboard

Log analysis and monitoring made easy!

Log4Net Dashboard is a log viewer that can read log statements from a variety of logging output targets.

You can download a free developer version.

  

Check it out!

On the demonstration site you can try it  with live data.demo.l4ndash.com - Try Log4Net Dashboard with live data

The mail archive is a copy of all the mail sent to the mail address: log4net-user@logging.apache.org, organized as a forum.

If you would like to participate in the mail list, send a mail to log4net-user-subscribe@logging.apache.org.

More information about the mailing list is available on: http://logging.apache.org/log4net/support.html

 

A complete topic list is available and can be viewed here (warning, it takes some time to load)

 

Copyright 2005-2008 by FaktNet AS Terms Of Use Privacy Statement