logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Watts <...@cliftonfarm.org>
Subject Re: How to address only one of the RootLogger?
Date Sun, 15 Aug 2010 17:06:44 GMT
You could do something like this:

In log4.properties:
        
        log4j.logger.only.paul=INFO,paul
        log4j.additivity.only.paul=false

In source code:

        Logger paul = Logger.getLogger("only.paul");
        paul.info("some info");


But I'm not so sure this is good from a design perspective...


On Sun, 2010-08-15 at 03:44 -0700, BenXS wrote:
> In Java I use currently Log4j as follows:
> 
> import org.apache.log4j.Logger;
> static Logger log = Logger.getLogger(this.getClass().getName())
> ...
> log.info("some info)";
> 
> 
> In the file "log4j.properties" I defined multiple RootLoggers like
> 
> log4j.rootLogger=INFO, paul, speciallog, ultra
> ....
> log4j.appender.paul=org.apache.log4j.FileAppender
> ...
> 
> How can I now direct some log output from inside a java program to ONLY
> the "paul" fileappender?
> 
> In other words: How do I have to specify in a java program that the
> log output should go ONLY to the file specified in the log4j.properties file
> which is declared for "paul"?
> 
> Do I have to write something like
> 
> log.info("paul","some info")
> 
> Ben?
> 

________
As far as the laws of mathematics refer to reality, they are not
certain; and as far as they are certain, they do not refer to reality.
-- Albert Einstein



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


Mime
View raw message