logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: log4j:ERROR Attempted to append to closed appender named [DEFAULT_LOGFILE].
Date Wed, 20 Jun 2007 15:26:15 GMT

On Jun 19, 2007, at 11:30 PM, Peter wrote:

> hi,all
>
> we are using log4j in our system. and it appeals  so many following  
> erros;
>
>  log4j:ERROR Attempted to append to closed appender named  
> [DEFAULT_LOGFILE].
>
> does anyone has an idea why and how to sovle it.
>
> thanks !
>
> here is our log4j.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
>
> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"  
> debug="false">
>
>  <appender name="OTHERS_LOGFILE"  
> class="org.apache.log4j.RollingFileAppender">
>   <param name="Threshold" value="DEBUG"/>
>   <param name="File" value="../logs/others.log"/>
>   <param name="Append" value="false"/>
>   <param name="MaxFileSize" value="2000KB"/>
>   <param name="MaxBackupIndex" value="10"/>
>   <layout class=" org.apache.log4j.PatternLayout">
>    <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
>   </layout>
>  </appender>
>
>  <appender name="DEFAULT_LOGFILE"  
> class="org.apache.log4j.RollingFileAppender">
>   <param name="Threshold" value="DEBUG"/>
>   <param name="File" value="../logs/shucoms.log"/>
>   <param name="Append" value="false"/>
>   <param name="MaxFileSize" value="2000KB"/>
>   <param name="MaxBackupIndex" value="10"/>
>   <layout class=" org.apache.log4j.PatternLayout">
>    <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
>   </layout>
>  </appender>
>
>
>  <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
>
>   <appender-ref ref="OTHERS_LOGFILE"/>
>
>   <appender-ref ref="DEFAULT_LOGFILE"/>
>
>  </appender>
>
>  <category name="gxlu.eoms" additivity="false">
>   <priority value="DEBUG"/>
>   <appender-ref ref="DEFAULT_LOGFILE"/>
>  </category>
>  <category name="org" additivity="false">
>   <priority value="INFO"/>
>   <appender-ref ref="OTHERS_LOGFILE"/>
>  </category>
>
> <!-- Setup the Root category -->
>  <root>
>   <priority value="DEBUG"/>
>   <appender-ref ref="ASYNC"/>
>  </root>
> </log4j:configuration>
>
>
>

The log4j-user mailing list would be the appropriate forum for this  
type of question.  Please do not respond to this message on  
general@logging.apache.org as this mailing list is for discussion  
that either applies to more than one of the projects or doesn't fit  
into any of the existing projects.

There are a couple of problems in your configuration file regarding  
AsyncAppender that could result in the problem that you are seeing.   
An instance of AsyncAppender wraps ONE appender and maintains the  
event queue and threads necessary to allow the application to  
continue before logging event processing is complete.  The appender  
wrapped by AsyncAppender is seldom if ever used directly after being  
wrapped.

In your configuration file, you attempt to wrap two appenders in one  
instance of AsyncAppender and you use both appenders independently of  
AsyncAppender.  Since the appenders are independently attached to  
loggers, they will be closed when the application is shut down which  
may be while the AsyncAppender is still dispatching deferred events  
to the appender.

If you avoid using wrapped appenders directly and do not attempt to  
wrap two appenders in one AsyncAppender, your problem will likely go  
away.

If you have any more questions or comments, please post them on log4j- 
user@logging.apache.org.


Mime
View raw message