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: Duplicate debug log
Prev Next
You are not authorized to post a reply.

Author Messages
Barbara Post

03/13/2009 10:50 AM  

Hello,

I use log4net 1.2.10 in an asp.net mvc site (.NET 3.5 SP1).

There may be something I misunderstood regarding loggers and additivity.

I have the following configuration :

[code]
<log4net>
    <appender name="Console" type="log4net.Appender.ConsoleAppender">
        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%-4timestamp [%thread] %-5level %logger %ndc - %message%newline" />
        </layout>
    </appender>

    <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
        <file value="logs/workflowpdf.log" />
        <appendToFile value="true" />
        <maximumFileSize value="100KB" />
        <maxSizeRollBackups value="2" />

        <layout type="log4net.Layout.PatternLayout">
            <conversionPattern value="%date [%thread] %level %logger - %message%newline" />
        </layout>
    </appender>

    <!-- Set root logger level to ERROR -->
    <root>
        <level value="ERROR" />
        <appender-ref ref="RollingFile" />
    </root>
    <!-- cas de debug de certaines classes -->
    <logger name="mycompany.myproject.firstnamespace.FirstClass">
        <level value="ERROR" />
        <appender-ref ref="Console" />
        <appender-ref ref="RollingFile" />
    </logger>
    <logger name="mycompany.myproject.secondnamespace.SecondClass">
        <level value="DEBUG" />
        <appender-ref ref="Console" />
        <appender-ref ref="RollingFile" />
    </logger>
</log4net>
[/code]

What I observe regarding debug log : FirstClass and SecondClass "debug" instructions are duplicated in the log file. Errors are not duplicated.

If I use <logger name="mycompany.myproject.firstnamespace.FirstClass" additivity="false"> and the same for the second logger, onlmy the FirstClass logger logs, despite the two classes belonging to different namespaces.

Here is the way I retrieve a logger in a class :

        private static readonly ILog logger = LogManager.GetLogger(typeof(FirstClass).FullName);

By the way, I don't know where to find "Console" appender with Visual Web Developper and its local development web server.

Maybe I could just remove this logger...

Thanks for any hint,

Barbara Post

You are not authorized to post a reply.
Forums > Log4Net > Log4Net Mail archive > Duplicate debug log



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