logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <c...@qos.ch>
Subject Re: Configuring Log4j for Application-only logging
Date Mon, 03 Mar 2003 18:54:17 GMT
Kevin,

I think appender additivity is at play. Your config file contains

  <category name="com.prospectinstitute.util.WarningLog">
     <priority value="WARN"/>
     <appender-ref ref="appwarn"/>   <---- here
   </category>
...
   <root>
     <appender-ref ref="CONSOLE"/>
     <appender-ref ref="FILE"/>
     <appender-ref ref="appwarn"/>   <-- and here
   </root>

which means that "appwarn" is attached to two different loggers.

For log4j documentation, see

http://jakarta.apache.org/log4j/docs/documentation.html

HTH,

At 01:53 PM 3/3/2003 -0500, you wrote:
>I would like to set up a set of separate loggers for my application
>messages, that only get messages that I specifically send to them.
>
>So, I would like to send all warning messages that are only from my
>application code to a logger that has an appender that is a file. Only
>messages that are warnings that my application code emits should
>get into this log.
>
>Here is the way I call the logger from Java (inside of WarningLog.java):
>============================================================================
>==
>logWarn = LogFactory.getLog("com.prospectinstitute.util.WarningLog");
>logWarn.warn("this is a warning");
>
>Here is the configuration in the XML file:
>============================================================================
>==
>...
>    <appender name="appwarn" class="org.apache.log4j.RollingFileAppender">
>     <param name="Threshold" value="WARN"/>
>     <param name="File"
>value="C:\\jbosstomcat\\server\\default\\deploy\\prospect.war\\logs\\warn.lo
>g"/>
>     <param name="MaxFileSize" value="100KB"/>
>     <param name="MaxBackupIndex" value="1"/>
>     <layout class="org.apache.log4j.SimpleLayout">
>     </layout>
>   </appender>
>...
>
>   <!-- Limit  only   -->
>   <category name="com.prospectinstitute.util.WarningLog">
>     <priority value="WARN"/>
>     <appender-ref ref="appwarn"/>
>   </category>
>...
>   <root>
>     <appender-ref ref="CONSOLE"/>
>     <appender-ref ref="FILE"/>
>     <appender-ref ref="appwarn"/>
>   </root>
>
>...
>============================================================================
>==
>
>Unfortunately, this log gets extraneous messages from other classes, like
>MainDeployer,
>that I have to limit to exclude from this log file (I'm using the
>JBOSS/Tomcat bundle).
>
>Like this:
>============================================================================
>==
>   <!-- Limit MainDeployer categories to ERROR   -->
>   <category name="org.jboss.deployment.MainDeployer">
>     <priority value="ERROR"/>
>   </category>
>
>It seems like it would be a common idea that you would want to send only
>your application messages
>to your own application log files. It seems like it should also be a common
>thing to do to place different levels
>of application messages in different log files. There should not be messages
>from any other classes
>in these files. And I don't want to turn off any messages for other classes
>that I don't control.
>
>But I can't seem to get it working right. Can you tell what I am doing
>wrong? I get the log messges to
>the specified file, but I feel I shouldn't have to exclude other classes.
>
>Could somone send me an example configuration (or corrections to mine) and
>any changes
>to the simple Java code?
>
>                                 Thanks,
>
>                                 Kevin L. O'Brien
>                         kevin.obrien@prospectinstitute.com

--
Ceki 


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


Mime
View raw message