2009/4/8 omatase <omat...@gmail.com>

>
>
> Daniel Marohn wrote:
> >
> > I did some research about this
> >
> > I checked the log4net sources. The error is thrown in
> > AppenderSkelleton (the base class of all appenders).
> > public void DoAppend(LoggingEvent[] loggingEvents)  {
> > ..
> > if (m_closed)
> >   {
> >     ErrorHandler.Error("Attempted to append to closed appender named
> > ["+m_name+"].");
> >     return;
> >   }
> > }
> >
> > m_closed in only set in
> > public void Close()
> >
> > it reads in code docu:
> > It is a programming error to append to a closed appender.
> >
> > Perhaps this is really a bug in one of the log4net appenders.
> >
> > Can you post a simple as possible config, that reproduces the error on
> > your system? I will try to reproduce this and debug into log4net to
> > see whats going wrong with the appender.
> >
> >
>
> Thanks for your help. Following is a minimalist example of one that fails.
> The error it causes is "log4net:ERROR [FileAppender] Attempted to append to
> closed appender named [FileAppender]." and can be seen in the Visual Studio
> "Output" window.
>
>
>  <log4net>
>    <root>
>      <level value="DEBUG" />
>      <appender-ref ref="FileAppender" />
>    </root>
>    <logger name="Invoicing">
>      <level value="DEBUG" />
>      <appender-ref ref="FileAppender" />
>    </logger>
>    <logger name="Invoicing">
>      <level value="FATAL" />
>      <appender-ref ref="FileAppenderFatal" />
>    </logger>
>    <!-- Setup the root category, add the appenders and set the default
> level -->
>    <appender name="FileAppender" type="log4net.Appender.FileAppender">
>      <file value="C:\Log.txt" />
>      <appendToFile value="true" />
>      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
>      <layout type="log4net.Layout.PatternLayout">
>        <conversionPattern value="%date [%thread] %-5level %logger
> [%property{NDC}] - %message%newline" />
>      </layout>
>    </appender>
>    <appender name="FileAppenderFatal" type="log4net.Appender.FileAppender">
>      <file value="C:\LogFatal.txt" />
>      <appendToFile value="true" />
>      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
>      <layout type="log4net.Layout.PatternLayout">
>        <conversionPattern value="%date [%thread] %-5level %logger
> [%property{NDC}] - %message%newline" />
>      </layout>
>    </appender>
>  </log4net>
>
> You'll see that although the example *may* not be practical, it should be
> possible. It's not super realistic for someone to want a FileAppender only
> for FATAL messages although it *could* happen. I replaced the
> AdoNetAppender
> with the FileAppenderFatal in the interest of making the smallest possible
> reproducible configuration.
>
> Interestingly, this configuration does *not* reproduce the error:
>
>  <log4net>
>    <root>
>      <level value="DEBUG" />
>      <appender-ref ref="FileAppender" />
>    </root>
>    <logger name="Invoicing">
>      <level value="FATAL" />
>      <appender-ref ref="FileAppenderFatal" />
>    </logger>
>    <logger name="Invoicing">
>      <level value="DEBUG" />
>      <appender-ref ref="FileAppender" />
>    </logger>
>    <!-- Setup the root category, add the appenders and set the default
> level -->
>    <appender name="FileAppender" type="log4net.Appender.FileAppender">
>      <file value="C:\Log.txt" />
>      <appendToFile value="true" />
>      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
>      <layout type="log4net.Layout.PatternLayout">
>        <conversionPattern value="%date [%thread] %-5level %logger
> [%property{NDC}] - %message%newline" />
>      </layout>
>    </appender>
>    <appender name="FileAppenderFatal" type="log4net.Appender.FileAppender">
>      <file value="C:\LogFatal.txt" />
>      <appendToFile value="true" />
>      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
>      <layout type="log4net.Layout.PatternLayout">
>        <conversionPattern value="%date [%thread] %-5level %logger
> [%property{NDC}] - %message%newline" />
>      </layout>
>    </appender>
>  </log4net>
>
> The only difference between the two was I swapped the positioning of the
> two
> loggers.
> --
> View this message in context:
> http://www.nabble.com/Error-destroying-my-productivity-Please-Help%21%3A-log4net%3AERROR----Attempted-to-append-to-closed-appender-named----tp22939427p22960695.html
>  Sent from the Log4net - Users mailing list archive at Nabble.com.
>
>

Reply via email to