logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Barbara Post" <bp...@actiwan.fr>
Subject Duplicate debug log
Date Fri, 13 Mar 2009 09:50:14 GMT

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 :

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

    <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"

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

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

View raw message