logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ognjen Blagojevic <ogn...@etf.bg.ac.yu>
Subject Re: HOw to replace the system.out.println
Date Mon, 01 Sep 2008 09:02:14 GMT
MY POI wrote:
> Dear all
> 
>            I want to use the logging system in my Project which consist of
> many modules developing by the 
> 
> much developers. Here I need to replace system.out.println statements and i
> want put loggers.
> 
> Is there any way to configuring one property file to replace the statements.
> 
> Many thanks in advance
> Rajesh

At the beginning of every class you should put:

   private static Logger logger = Logger.getLogger(ClassName.class);

Than, instead of

   System.out.println("...");

use

   logger.logMethod("...")

where logMethod is info/warning/debug etc.

In the end, put log4j.properties in the src.folder:

------log4j.properties------
log4j.rootLogger=info, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%m%n
----------------------------

That should be enough to begin working.

Regards,
Ognjen

---------------------------------------------------------------------
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