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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to