At 00:08 14.03.2001 -0800, msew wrote: >At 00:20 03/14/2001 -0500, Peter Lin wrote: > >>Do anyone have an example of filtering by class with DOMConfigurator. I >>don't see a filter for it. There's priority and string filter, but no >>class filter. In the non-xml configuration, the sample given is this. >> >> log4j.category.org.apache.log4j.examples.SortAlgo.INNER=INFO >> >>if any one has an example or knows of one, can you point to it. thanks >>in advance. >> >>peter > > > >this is an example of what I was using. (I should have a new one soonish :-) ) if >there is something bad please do blast it into smitherings :-) > > >I pretty much think in xml and objects and .properties files just make me have >nightmares. :-) > > >the problem that I had in pre 1.1b (I have not gotten to testing in 1.1b yet.) is >this: > > > ><!DOCTYPE configuration SYSTEM "log4j.dtd"> > > > ><configuration> > > <appender name="defaultThreadLogger" class="org.apache.log4j.FileAppender"> > <param name="File" value="System.out" /> > <param name="Append" value="true" /> > > <layout class="org.apache.log4j.PatternLayout"> > <param name="ConversionPattern" > value="[%d{HH:mm:ss,SSS}]# [ %-5p] userid: %t %x %m \n" /> > </layout> > > </appender> > > ><!-- this is of the entire project that everyone else inherits off of --> > <root> > <priority value ="error" /> > <appender-ref ref="defaultThreadLogger" /> > </root> > > ><!-- start of the robots.util PACKAGE --> > > <category name="foo.bar.robots.util"> > <priority value="info" /> ><!-- <appender-ref ref="defaultThreadLogger" /> --> > </category> > > ><!-- end of the robots.util PACKAGE --> > > ></configuration> > > > > >If you uncomment <!-- <appender-ref ref="defaultThreadLogger" /> --> >then when foo.bar.robots.util fires you will get the appender "firing" 2x. >it seems that the xml parser inserts the appender-ref into the list of appenders >without checking to see if that appender is already inserted. (I can't recall if I >submitted this as a bug already. I know I wanted to. but life just blurs and you >think you did something but instead it was a cafeine induced haze.) This is not a bug. The DOMConfigurator does not do duplicate elimination. Moreover, I assume you are aware of the additive appender inheritance in log4j. >msew > > >------- see below for the .xml file example --------- > > > ><!-- <!DOCTYPE configuration SYSTEM "log4j.dtd"> --> > ><!DOCTYPE configuration SYSTEM "log4j.dtd"> > > > ><configuration> > > <appender name="defaultThreadLogger" class="org.apache.log4j.FileAppender"> > <param name="File" value="System.out" /> > <param name="Append" value="true" /> > > <layout class="org.apache.log4j.PatternLayout"> > <param name="ConversionPattern" > value="[%d{HH:mm:ss,SSS}]# [ %-5p] userid: %t %x %m \n" /> > </layout> > > </appender> > > ><!-- this is of the entire project that everyone else inherits off of --> > <root> > <priority value ="error" /> > <appender-ref ref="defaultThreadLogger" /> > </root> > > ><!-- start of the robots.util PACKAGE --> > > <category name="foo.bar.robots.util"> > <priority value="info" /> ><!-- <appender-ref ref="defaultThreadLogger" /> --> > </category> > > ><!-- end of the robots.util PACKAGE --> > > > > > ><!-- start of the robots.client PACKAGE --> > > <category name="foo.bar.client"> > <priority value="info" /> > <!-- <appender-ref ref="defaultNetworkLogger" /> --> > </category> > > ><!-- start of the BootStrap --> > <category name="foo.bar.client.BootStrap"> > <priority value="info" /> > <!-- <appender-ref ref="defaultNetworkLogger" /> --> > </category> ><!-- end of the BootStrap --> > > > ><!-- start of the BotThreadImpl --> > <category name="foo.bar.client.BotThreadImpl"> > <priority value="info" /> > <!-- <appender-ref ref="defaultNetworkLogger" /> --> > </category> ><!-- end of the BotThreadImpl --> > > ><!-- end of the robots.client PACKAGE --> > > > > > ><!-- start of the robots.common.thread PACKAGE --> > > <category name="foo.bar.common.thread"> > <priority value="warn" /> > <!-- <appender-ref ref="defaultThreadLogger" /> --> > </category> > > > > ><!-- start of the PingMessageThreadImpl --> > <category name="foo.bar.common.thread.PingMessageThreadImpl"> > <priority value="debug" /> > <!-- <appender-ref ref="defaultThreadLogger" /> --> > </category> > ><!-- end of the PingMessageThreadImpl --> > > > ><!-- start of the PingMessageThreadLobbyImpl --> > <category name="foo.bar.common.thread.PingMessageThreadLobbyImpl"> > <priority value="warn" /> > <!-- <appender-ref ref="defaultThreadLogger" /> --> > </category> > ><!-- end of the PingMessageThreadLobbyImpl --> > > > ><!-- end of the robots.common.thread PACKAGE --> > > > > ><!-- start of the robots.common.network PACKAGE --> > > <category name="foo.bar.common.network"> > <priority value="debug" /> > <!-- <appender-ref ref="defaultNetworkLogger" /> --> > </category> > > ><!-- start of the RobotNetworkConnectionLobbyImpl --> > <category name="foo.bar.common.network.RobotNetworkConnectionLobbyImpl"> > <priority value="debug" /> > <!-- <appender-ref ref="defaultNetworkLogger" /> --> > </category> ><!-- end of the RobotNetworkConnectionLobbyImpl --> > > > ><!-- start of the RobotNetworkConnectionLobbyImpl --> > <category name="foo.bar.common.network.RobotNetworkConnectionGameServerImpl"> > <priority value="debug" /> > <!-- <appender-ref ref="defaultNetworkLogger" /> --> > </category> ><!-- end of the RobotNetworkConnectionLobbyImpl --> > > > ><!-- end of the robots.common.network PACKAGE --> > ></configuration> OK. This is from the log4j manual: ======================================================= A category may refer to multiple appenders. The addAppender method adds an appender to a given category. Each enabled logging request for a given category will be forwarded to all the appenders in that category as well as the appenders higher in the hierarchy. In other words, appenders are inherited additively from the category hierarchy. For example, if a console appender is added to the root category, then all enabled logging requests will at least print on the console. If in addition a file appender is added to a category, say C, then enabled logging requests for C and C's children will print on a file and on the console. It is possible to override this default behavior so that appender accumulation is no longer additive by setting the additivity flag to false. The rules govening appender addivity are sumarized below. Appender Additivity ==================== The output of a log statement of category C will go to all the appenders in C and its ancestors. This is the meaning of the term "appender additivity". However, if an ancestor of category C, say P, has the additivity flag set to false, then C's output will be directed to all the appenders in C and it's ancestors upto and including P but not the appenders in any of the ancestors of P. Categories have their additivity flag set to true by default. ======================================================== Hope this helps, Ceki I hope to see you at my ApacheCon 2001 presentation entitled "Log4j, A Logging Package for Java". See http://ApacheCon.Com/2001/US/ for more details. ---- Ceki Gülcü Web: http://qos.ch av. de Rumine 5 email: [EMAIL PROTECTED] (preferred) CH-1005 Lausanne [EMAIL PROTECTED] Switzerland Tel: ++41 21 351 23 15 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]