All right all; I think I got what I want... thanks!

------

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

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/";>

    <appender name="console.out" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" value="%6r [%t] %5p %c.%M:%L -
%m%n"/>
        </layout>
    </appender>
    
    <appender name="struts-log" class="org.apache.log4j.FileAppender">
                <param name="File"   value="struts_log.log" />
          <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" value="%6r [%t] %5p %c.%M:%L -
%m%n"/>
          </layout>
    </appender>
        
    <category name="org.apache.struts">
        <priority value="debug"/>
        <appender-ref ref="struts-log"/>
    </category>
          
    <category name="org.apache.commons">
        <priority value="info"/>
        <appender-ref ref="console.out"/>
    </category>

     <root>
        <priority value="warn"/>
        <appender-ref ref="console.out"/>
     </root>
    
</log4j:configuration>



Thanks



-----Original Message-----
From: Babu, Bharathi [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 23, 2004 9:41 AM
To: '[EMAIL PROTECTED]'
Subject: FW: component level log


True, I think I should've explained my situation more...
We are using commons Fa�ade for logging. So, my ability to interact direct
log4j is pretty limited.

I'm trying to find a good example of a log4j.xml explain me how to-do this.
 
Thanks

-----Original Message-----
From: Michael Coughlan [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 23, 2004 9:28 AM
To: [EMAIL PROTECTED]
Subject: RE: component level log

> Hello team,
> I'm starting with log4j here, I got a situation in my 
> project.. I appreciate
> any of your suggestion. 
> I got many core components in my app... Let's say 
> org.myapp.security.*
> org.myapp.admin.*
> org.myapp.navigation.* 
> I like to get each of the component logs at different 
> priority and different

Log 4j was designed to do exactly that.

Have you built a hello world program yet?

The constructors will show you how to control logging granularity.

I am new as well. Here's a program I wrote. 

Pay attention to all the object that are necesasry to instanciate the
logger. 

Play with their settings to achieve your desired output control.

I hope that helps.

MPC


public class TestLogger {
        static Logger myLogger = Logger.getLogger("TestLogger");
        
        public static void main(String[] args) {
                File myFile = null; 
                FileOutputStream myFileOS = null;
                PatternLayout myLayout = null;
                WriterAppender myAppender = null;
                
                System.out.println("Writing to file...");
                try {
                    myFile = new File("foo.out");
                        myFileOS = new FileOutputStream (myFile);
                }catch (Exception e) {
                        System.out.println(e.toString());
                }
                myLayout = new PatternLayout("%m%n");
                myAppender = new WriterAppender(myLayout, myFileOS);
                myLogger.addAppender(myAppender);
                myLogger.setLevel(Level.DEBUG);
                myLogger.debug("Hello World with a patternLayout");
        }
} 

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

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

Reply via email to