You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by pudsinuk <da...@hotmail.com> on 2010/01/21 18:19:07 UTC

stdout in configuration

Hello
I am trying to send stdout (system.out.println) through to the log4j logger
but i dont want to use an extra configuration file.  I know there is a way
to do this through an external file with a line like: 
"log4j.rootCategory = DEBUG, stderr, stdout" 
but i would just like to do this in a class

I have the following in my class:

public class Util_Logger{
    static Logger logger = Logger.getRootLogger();

   static{
       FileAppender appender = new FileAppender(new SimpleLayout(),
LOG_LOCATION);
       logger.addAppender(appender);
       logger.setLevel(LEVEL.ERROR);
    }
}

somebody help please??
-- 
View this message in context: http://old.nabble.com/stdout-in-configuration-tp27261344p27261344.html
Sent from the Log4j - Dev mailing list archive at Nabble.com.


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


AW: stdout in configuration

Posted by Bender Heri <hb...@ergonomics.ch>.
First: You're on the wrong mailing list. This is the developper list. Ask such questions on the users list.
Second: you cannot intercept System.out.print by log4j. Your example does the opposite: it writes log statements (e.g. myLogger.debug( "message" )) to an appender called stderr and stdout.
In order to intercept System.out.print you have to replace the OutputStream by an own one and then do something with it.
Heri

-----Ursprüngliche Nachricht-----
Von: pudsinuk [mailto:dan_pudwell@hotmail.com] 
Gesendet: Donnerstag, 21. Januar 2010 18:19
An: log4j-dev@logging.apache.org
Betreff: stdout in configuration


Hello
I am trying to send stdout (system.out.println) through to the log4j logger but i dont want to use an extra configuration file.  I know there is a way to do this through an external file with a line like: 
"log4j.rootCategory = DEBUG, stderr, stdout" 
but i would just like to do this in a class

I have the following in my class:

public class Util_Logger{
    static Logger logger = Logger.getRootLogger();

   static{
       FileAppender appender = new FileAppender(new SimpleLayout(), LOG_LOCATION);
       logger.addAppender(appender);
       logger.setLevel(LEVEL.ERROR);
    }
}

somebody help please??
--
View this message in context: http://old.nabble.com/stdout-in-configuration-tp27261344p27261344.html
Sent from the Log4j - Dev mailing list archive at Nabble.com.


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


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