Dear Bender,
 
Thanks four your xml sample now it works as I expect, on the attached file you will find it.
 
Nevertheless I have some comments, I am not log4j expert, but I guess the syntax could be simplified, and probably it is possible:
 
1. With your suggestion, I have to specify explicit each external library, but the opossite would be easier to define, but I don't know how to set it, all my classes belong to the package: com.schinvest, so this package will be at INFO level for console, file, and htmlFile, any thing else will have WARNING level for all appenders. Probably this could be configurate in simpler way, but I don't know how to do it.
 
2. On cathegory node there is no way on the class attribute to specify more than one class at the same time, is that true?
 
<category name="org, net.sf">
        <level value="warn"></level>
        <appender-ref ref="file"/>
        <appender-ref ref="htmlFile"/>
</category>
 
so this cathegory will be applied for org.* and net.sf.* packages, that would simplify the log4 configuration, but I have tested it and it doesn't work.
 
Thanks for your help,
 
David

Bender Heri <[EMAIL PROTECTED]> wrote:
Here is an example of an xml configuration which uses filters (BTW: Using this two appenders when debugging in eclipse the console shows the DEBUG and INFO in black color and the others in red color). You can also write your own filter class where you are free to filter what you want. Be careful on the ordering when extending this xml file. The logj4 parser expects first all appenders followed by all loggers.









































Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<!--
This configuration defines three appenders:
console: With warn level
file: With debug level four all classes except for external libraries of 
         our application.
htmlFile: With the same configuration as console, except for HTML format.
-->

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"; debug="false">
   
     <appender name="stdout" 
         class="org.apache.log4j.ConsoleAppender">
         <param name="target" value="System.out"/>
         <param name="ImmediateFlush" value="true"/>
         <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" 
                 value="%5p%x[%M](%C{1}:%L) - %m%n"/>
         </layout>
         <filter class="org.apache.log4j.varia.LevelRangeFilter">
             <param name="LevelMin" value="info"/>
             <param name="LevelMax" value="fatal"/>
             <param name="AcceptOnMatch" value="false"/>
         </filter>
     </appender>
          
     <appender name="file" 
         class="org.apache.log4j.DailyRollingFileAppender">
         <!--param name="target" value="System.err"/-->
         <param name="File" value="log/lra.log"/>
         <param name="Append" value="false"/>
         <param name="DatePattern" value="'.'yyyy-MM-dd"/>
         <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" 
                 value="[%d{yyyy-MM-dd hh:mm:ss},%6.6r]%5p%x[%M](%C{1}:%L) - %m%n"/>
         </layout>
         <filter class="org.apache.log4j.varia.LevelRangeFilter">
             <param name="LevelMin" value="debug"/>
             <param name="LevelMax" value="fatal"/>
             <param name="AcceptOnMatch" value="false"/>
         </filter>
     </appender>
     
    <appender name="htmlFile" class="org.apache.log4j.DailyRollingFileAppender">
        <param name="File" value="log/lra_log.html"/>
        <param name="Append" value="false"/>        
        <layout class="org.apache.log4j.HTMLLayout">
            <param name="Title" value="LRA log Information"/>
            <param name="LocationInfo" value="true"/>
        </layout>
        <filter class="org.apache.log4j.varia.LevelRangeFilter">
            <param name="LevelMin" value="info"/>
            <param name="LevelMax" value="fatal"/>
            <param name="AcceptOnMatch" value="false"/>
        </filter>        
    </appender>
    
     
    <!--We filter now by classes setting the main pattern on the name attribute
    Note: You can't concatenate the class names on one category, for example:
    putting in the name="org, net.sf" together.--> 
    <category name="org">
        <level value="warn"></level>
        <appender-ref ref="file"/>
        <appender-ref ref="htmlFile"/>
    </category>
    
    <category name="net.sf">
        <level value="warn"></level>
        <appender-ref ref="file"/>
        <appender-ref ref="htmlFile"/>
    </category>
    
    <category name="oracle">
        <level value="warn"></level>
        <appender-ref ref="file"/>
        <appender-ref ref="htmlFile"/>
    </category>
    
    <category name="com.OsterMiller">
        <level value="warn"></level>
        <appender-ref ref="file"/>
        <appender-ref ref="htmlFile"/>
    </category>
    
    <category name="com.keypoint">
        <level value="warn"></level>
        <appender-ref ref="file"/>
        <appender-ref ref="htmlFile"/>
    </category>
   
    <category name="javax.servlet, javax.transaction">
        <level value="warn"></level>
        <appender-ref ref="file"/>
        <appender-ref ref="htmlFile"/>
    </category>
             
     <root>
         <level value="debug"/>
         <appender-ref ref="stdout"/>
         <appender-ref ref="file"/>
         <appender-ref ref="htmlFile"/>
     </root>
     
 </log4j:configuration>
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to