Monday, May 5, 2014

Application.log , Selenium.log and log4j.properties files





Application.log , Selenium.log and log4jproperties


Log4j.properties file in our framework, logs all Selenium related information into “Selenium.log” file and application related information into “Application.log” file.
a.       Download “log4j.jar” from http://www.java2s.com/Code/Jar/l/Downloadlog4jjar.htm and add to your build path of your project.
b.      Create “Application.log” ,”Selenium.log” and “log4j.properties” file in your Project, package as shown in screenshot.
c.       Add the contents in screen shot into the “log4j.properties” file and change the path of selenium and application log files .
d.      Application.log and Selenium.log remains empty.
e.      Add the following lines in your main code .
Now after execution, click on Project rt clk >Refresh . To see updated logs .
Note : To update your application.log , use below code :
your_class.APPLICATION_LOGS.debug("message");


//----------------------log4j.properties--------------------------------------
#Root logger option
log4j.rootLogger=debug,file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=D:\\USA Today\\Sigma_Selenium\\src\\src\\Selenium.log
log4j.appender.file.maxFileSize=5000KB
log4j.appender.file.maxBackupIndex=1
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
#do not append the old file. Create a new log file everytime
log4j.appender.file.Append=false

#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=D:\\USA Today\\Sigma_Selenium\\src\\src\\Application.log
#do not append the old file. Create a new log file everytime
log4j.appender.dest1.Append=false
//---------------------------------------------------------------------------

No comments:

Post a Comment