Log4J
1.Get the jar file and configure in project.
2.Create a Log4j.properties file in project.
#Application Logs
log4j.logger.devpinoyLogger=DEBUG, dest1
log4j.appender.dest1=org.apache.log4j.RollingFileAppender
log4j.appender.dest1.maxFileSize=5000KB
log4j.appender.dest1.maxBackupIndex=3
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} %c %m%n
log4j.appender.dest1.File=F:\\AfterMarriage\\Log4j\\Application.log
#do not append the old file. Create a new log file everytime
log4j.appender.dest1.Append=false
3.Call the Logger class
import org.apache.log4j.Logger;
public class TestLog {
public static void main (String[]args){
Logger Application_Logs = Logger.getLogger("devpinoyLogger");
Application_Logs.debug("Starting the Programme");
Application_Logs.debug("Running the Programme");
Application_Logs.debug("Processing the Programme");
Application_Logs.debug("Optimising the Programme");
Application_Logs.debug("Scrubbing the Programme");
Application_Logs.debug("Ebvaluating the Programme");
}
}
2.Create a Log4j.properties file in project.
#Application Logs
log4j.logger.devpinoyLogger=DEBUG, dest1
log4j.appender.dest1=org.apache.log4j.RollingFileAppender
log4j.appender.dest1.maxFileSize=5000KB
log4j.appender.dest1.maxBackupIndex=3
log4j.appender.dest1.layout=org.apache.log4j.PatternLayout
log4j.appender.dest1.layout.ConversionPattern=%d{dd/MM/yyyy HH:mm:ss} %c %m%n
log4j.appender.dest1.File=F:\\AfterMarriage\\Log4j\\Application.log
#do not append the old file. Create a new log file everytime
log4j.appender.dest1.Append=false
3.Call the Logger class
import org.apache.log4j.Logger;
public class TestLog {
public static void main (String[]args){
Logger Application_Logs = Logger.getLogger("devpinoyLogger");
Application_Logs.debug("Starting the Programme");
Application_Logs.debug("Running the Programme");
Application_Logs.debug("Processing the Programme");
Application_Logs.debug("Optimising the Programme");
Application_Logs.debug("Scrubbing the Programme");
Application_Logs.debug("Ebvaluating the Programme");
}
}
Comments
Post a Comment