logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Schultz" <dschu...@atstransportation.com>
Subject RE: Log4J Setup using XML Configuration File
Date Thu, 04 Oct 2001 17:13:01 GMT
While it is true that a Category can have multiple appenders, neither the
properties file definition nor the log4j.dtd have syntax for assigning a
Priority to an Appender.  Priority is assigned to the Category.

Also, don't forget the inheritance of Categories.  The Category
"com.lycos.subscriber.lSubscriber" inherits the behavior of "com.lycos" and
of "root"  (unless you set "additivity" for the Category to "false").

Hope this info helps...

-----Original Message-----
From: Scott.Whitecross@corp.terralycos.com
[mailto:Scott.Whitecross@corp.terralycos.com]
Sent: Thursday, 04.October 2001 12:42
To: log4j-user@jakarta.apache.org
Subject: Log4J Setup using XML Configuration File


First, a quick question: Its my assumption that each log4j category can
have muliple appenders.  Each appender for a category can also have its own
priority.  In theory, this means I can log all debug messages for a
category to one file, all error messages to another file, and warning
messages to stdout, if I desire.

If the answer to the above is yes, does the xml configuration class for
log4j allow for this?  I haven't been able to setup an XML file to attach
multiple appenders, each with different priorites to categories.  The last
appender's priority in the xml file seems to cancel out previous appenders'
priorities.

Here's my xml file below.  The last appender to a subcategory, causes all
logging messages to appear in my error log, which, in theory it shouldn't.
If multiple categories are included, it looks like the xml configuration
tool ignore the previous entry as well.

Thanks,
Scott

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'
disableOverride="false" debug="true">
     <appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
             <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern"
              value="[%-5p] [%d{ISO8601}] [%-40.25c]     %m%n"/>
           </layout>
     </appender>

     <appender name="FILELOG" class="org.apache.log4j.FileAppender">
            <param name="File"   value="..\\logs\\subscriber.log" />
            <param name="Append" value="true" />
            <layout class="org.apache.log4j.PatternLayout">
                    <param name="ConversionPattern" value="[%-5p]
[%d{ISO8601}] [%-40.25c]     %m%n"/>
            </layout>
     </appender>

     <appender name="ERRORLOG" class="org.apache.log4j.FileAppender">
            <param name="File"   value="..\\logs\\subscribererror.log" />
            <param name="Append" value="true" />
            <layout class="org.apache.log4j.PatternLayout">
                    <param name="ConversionPattern" value="[%-5p]
[%d{ISO8601}] [%-40.25c]     %m%n"/>
            </layout>
     </appender>

     <category name="root">
          <priority value="info" />
          <appender-ref ref="STDOUT" />
          <appender-ref ref="FILELOG" />
     </category>

     <category name="com.lycos">
          <priority value="error" />
          <appender-ref ref="ERRORLOG" />
     </category>

     <category name="com.lycos.subscriber.lSubscriber">
          <priority value="debug" />
          <appender-ref ref="STDOUT" />
          <appender-ref ref="FILELOG" />
     </category>

</log4j:configuration>



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



---------------------------------------------------------------------
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