Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4j: log4j:ERROR Attempted to append to closed appender named [stdout]

Tags:

log4j

What is meant by "Attempted to append to closed appender " ?

The following is a small part of my log4j.xml file

<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
    <param name="Threshold" value="TRACE" />
    <param name="Target" value="System.out" />
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d %-5p: %m%n" />
    </layout>
</appender>

<logger name="java.sql" additivity="false">
    <level value="trace" />
    <appender-ref ref="stdout" />
</logger>

I am trying to print some sql queries out , but I am getting the above error . Am I missing something ?

like image 870
Vinoth Kumar C M Avatar asked May 16 '11 12:05

Vinoth Kumar C M


2 Answers

I got this message when my log4j.xml contained, due to a copy-and-dont-edit, two loggers (aka categories) with the same name linked to the same appender.

like image 190
Pino Avatar answered Jan 01 '23 20:01

Pino


In my case, I used 2 logger elements on same package name caught into this error. removing one of them solved the problem.

<logger name="org.activiti.engine" additivity="false">
    <level value="error" />
    <appender-ref ref="LOGFILE" />
  </logger>
  <logger name="org.activiti.engine" additivity="false">
    <level value="debug" />
    <appender-ref ref="activitiBPMLog" />
  </logger>
like image 31
Swamy Avatar answered Jan 01 '23 19:01

Swamy