log4j.properties
log4j.rootCategory=INFO,file
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.DatePattern='.'yyyy-MM-dd
log4j.appender.file.File=run.log
log4j.appender.file.Append=true
log4j.appender.file.Threshold=INFO
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss:SSS}-%p-%m-%l%n
Log4jControls
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
public class Log4jControls {
private static Logger logger =null;
public static Logger getLogger() {
return logger;
}
public static Logger initializeLog4jControls()
{
if(logger==null)
{
PropertyConfigurator.configure("log4j.properties");
logger = Logger.getLogger(Log4jControls.class);
logger.setLevel(Level.INFO);
}
return logger;
}
}