The reason the order of the tags is important is that the XML configuration file is 
validated with the log4j.dtd.  In DTDs, you specify tags and whether they are required 
or not.  And, as part of that specification (and validation), a tag order is enforced.

Here's the logger DTD snippet:

<!ELEMENT logger (level?,appender-ref*)>
<!ATTLIST logger
  name          ID      #REQUIRED
  additivity    (true|false) "true"  
>

The fact that level precedes appender-ref imposes that order within the XML.

Sorry folks, suffering from "too much info" here!

--Mark

-----Original Message-----
From: Jacob Kjome [mailto:hoju@;visi.com]
Sent: Wednesday, November 06, 2002 2:47 PM
To: Log4J Users List
Subject: RE: Can groups of classes be assigned independent appenders?



Sorry about that.  I was just copy/pasting.  I should have been more 
careful making sure the name of the appender-ref matched the appender.  I 
Didn't test the actual deal that I put there.  It does seems odd, though, 
that order of the tags should matter, but I suppose that is the case for 
web.xml.  Whatever.  As long as it works :-)

Glad I could help.

Jake

At 12:02 PM 11/6/2002 -0800, you wrote:
>Yes, this is what I am looking for.  Thanks much.
>
>However, in your example, the logger should be more like this:
>
><logger name="org.myorganization.mypackage.mysubpackage" additivity="false">
>          <level value="debug"/>
>          <appender-ref ref="A1"/>
></logger>
>
>where the level tag precedes the appender-ref tag, and the appender-ref 
>ref attribute is the name of the appender.
>
>--Mark
>
>
>-----Original Message-----
>From: Jacob Kjome [mailto:hoju@;visi.com]
>Sent: Tuesday, November 05, 2002 12:51 PM
>To: Log4J Users List
>Subject: Re: Can groups of classes be assigned independent appenders?
>
>
>
>It all depends on how you name your loggers.  The common way to name your
>loggers is, of course,
>
>private static final Logger logger = 
>Logger.getLogger(MyClass.class.getName());
>
>this would end up being called something like:
>
>org.myorganization.mypackage.mysubpackage.MyClass
>
>to have every class in "mysubpackage" have logging enabled for the level
>"debug" I'd do:
>
><appender name="A2" class="org.apache.log4j.FileAppender">
>      <param name="File" value="c:\main.log" />
>      <param name="Append" value="false" />
>      <layout class="org.apache.log4j.PatternLayout">
>          <param name="ConversionPattern" value="%-4r [%t] %-5p %c %x - 
> %m%n"/>
>      </layout>
></appender>
>
><logger name="org.myorganization.mypackage.mysubpackage" additivity="false">
>          <appender-ref ref="MyFileAppender"/>
>          <level value="debug"/>
></logger>
>
>Notice the additivity="false".  If I didn't have that, I'd also be logging
>what the <root> logger or any other logger this logger might be inheriting
>from had defined to log.
>
>Is that what you were looking for?
>
>Jake
>
>
>At 11:32 AM 11/5/2002 -0800, you wrote:
> >Can a class or group of classes be assigned to appenders independently
> >from other classes?
> >
> >I'd like to implement a message driven bean in Jboss and I'd like the
> >output of that bean to go to a log file other then the standard
> >application server log.
> >
> >Thanks,
> >Mark
> >
> >--
> >To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@;jakarta.apache.org>
> >For additional commands, e-mail: <mailto:log4j-user-help@;jakarta.apache.org>
>
>--
>To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@;jakarta.apache.org>
>For additional commands, e-mail: <mailto:log4j-user-help@;jakarta.apache.org>

--
To unsubscribe, e-mail:   <mailto:log4j-user-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:log4j-user-help@;jakarta.apache.org>

Reply via email to