Log4j errors | Selenium Forum
M
Posted on 01/06/2016
I followed these 3 steps :

1. Included Log4j Jars in libraries of my project.
2. Created Log4j.properties file
3. Added the following parameters in the file :

#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:\\Temp\\Test.log
#do not append the old file. Create a new log file everytime
log4j.appender.dest1.Append=false

4. Created a new Java file as Test_log4j and inside it wrote this code :-

import org.apache.log4j.Logger;

public class Test_log4j {

public static void main(String[] args) {

Logger APPLICATION_LOGS=Logger.getLogger("devpinoyLogger");
APPLICATION_LOGS.debug("starting");
APPLICATION_LOGS.debug("executing");
APPLICATION_LOGS.debug("ending");

}

}

After running I am getting the following error :

" log4j:WARN No appenders could be found for logger (devpinoyLogger).
log4j:WARN Please initialize the log4j system properly. "

I deleted the log4j.properties file and the class file and created again. Still getting the same error. Please help.

Thanks
Sankalp

M
Replied on 01/06/2016

try this

[code:1vuhqxa8]#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=C:\\testing\\Application.log
#do not append the old file. Create a new log file everytime
log4j.appender.dest1.Append=false
[/code:1vuhqxa8]

[code:1vuhqxa8]package com.soapuitutorial.propertie;
import org.apache.log4j.Logger;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;


public class Logging_Example {

/**
* @param args
*/
public static void main(String[] args) {

// add log4j.jar
// add log4j.propertie directly inside the src folder
// create the object in the code
HtmlUnitDriver qwer=new HtmlUnitDriver();
Logger APPLICATION_LOGS = Logger.getLogger("devpinoyLogger");
APPLICATION_LOGS.debug("hello");
APPLICATION_LOGS.debug("We are wrinting in to a log file");
APPLICATION_LOGS.debug("starting the test case xyz test");


}

}
[/code:1vuhqxa8]


M
Replied on 02/06/2016

Still not working Responsive image....Any other option?


M
Replied on 03/06/2016

create a new project and download all the log4j jar files again. then try again.


M
Replied on 05/06/2016

It worked this time. Actually I placed Log4j.properties file directly in bin folder from src folder. And ran the program again

Thanks
Sankalp