logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin O'Brien" <kevin.obr...@prospectinstitute.com>
Subject Configuring Log4j for Application-only logging
Date Mon, 03 Mar 2003 18:53:06 GMT
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



Mime
View raw message