logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Norbert Toth-Gati" <norbert.tothg...@gmail.com>
Subject Re: How do I configure Log4J to send different levels to different appenders
Date Wed, 04 Jul 2007 12:05:13 GMT
Hi,
Concerning the :"log4j:ERROR Attempted to append to closed appender named
[MAIN_LOG]." Please follow the link, as a similar problem is discussed:
http://www.mail-archive.com/log4j-user@jakarta.apache.org/msg01365.html

Yep, you cannot use root-element for that.

Regards,
Norbert

On 7/4/07, Mikael Ståldal <mikael.staldal@univits.com> wrote:
>
> Norbert Toth-Gati wrote:
> > You may try to configure the following categories:
> >
> >    <category name="com.mycompany">
> >        <priority value="DEBUG"/>
> >        <appender-ref ref="MAIN_LOG"/>
> >        <appender-ref ref="DEBUG_LOG"/>
> >    </category>
> >
> >    <category name="com.othercompany">
> >        <priority value="WARN"/>
> >        <appender-ref ref="MAIN_LOG"/>
> >    </category>
> >
> >    <category name="com.othercompany">
> >        <priority value="DEBUG"/>
> >        <appender-ref ref="DEBUG_LOG"/>
> >    </category>
>
> It doesn't work. I end up with an empty MAIN_LOG and the following error
> message:
>
> log4j:ERROR Attempted to append to closed appender named [MAIN_LOG].
>
> > You may need to configure all the thirdparty logs to end up in the
> > following appenders:
> >
> >    <category name="org.thirdparty">
> >        <priority value="ERROR"/>
> >        <appender-ref ref="MAIN_LOG"/>
> >    </category>
> >    <category name="org.thirdparty">
> >        <priority value="INFO"/>
> >        <appender-ref ref="DEBUG_LOG"/>
> >    </category>
>
> I would prefer to have a catch-all rule. I guess that the <root> element
> can be used for
> that, but you can only have one <root> element.
>
> Here is the complete log4j.xml I tested with:
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
>
>     <appender name="DEBUG_LOG" class="
> org.apache.log4j.DailyRollingFileAppender">
>        <param name="File" value="debug.log" />
>        <param name="Append" value="false" />
>        <layout class="org.apache.log4j.PatternLayout">
>            <param name="ConversionPattern" value="%d %-5p [%t] %c -
> %m%n"/>
>        </layout>
>     </appender>
>
>     <appender name="MAIN_LOG" class="
> org.apache.log4j.DailyRollingFileAppender">
>        <param name="File" value="main.log" />
>        <param name="Append" value="false" />
>        <layout class="org.apache.log4j.PatternLayout">
>            <param name="ConversionPattern" value="%d %-5p [%t] %c -
> %m%n"/>
>        </layout>
>     </appender>
>
>     <category name="com.mycompany">
>         <priority value="DEBUG"/>
>         <appender-ref ref="MAIN_LOG"/>
>         <appender-ref ref="DEBUG_LOG"/>
>     </category>
>
>     <category name="com.othercompany">
>         <priority value="WARN"/>
>         <appender-ref ref="MAIN_LOG"/>
>     </category>
>
>     <category name="com.othercompany">
>         <priority value="DEBUG"/>
>         <appender-ref ref="DEBUG_LOG"/>
>     </category>
>
> </log4j:configuration>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message