# Root logger option log4j.rootLogger=ERROR, stdout, file # Redirect log messages to a log file, support file rolling. log4j.appender.file=org.apache.log4j.BasicConfigurator;RollingFileAppenderimport org log4j.apacheappender.log4j.Logger; public class Log4jHelloWorld { static final Logger logger = Logger.getLogger(Log4jHelloWorld.class); public static void main(String[] args) { //Configure logger BasicConfigurator.configure(); for(int i=0;i<20000;i++) { System.out.println("Hello World!"+i); logger.info("Hello World!"+i); } } } |