Log4j WARNING | Selenium Forum
M
Posted on 04/02/2016
Hi ,

Upon executing the below code , it came up with log4j warning

Code:


package LearningTestNG;



import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.apache.log4j.Logger;

public class Object1 {

public static Logger APPLICATION_LOG = Logger.getLogger("devpinoyLogger");

@Test ()

public void mytest(){
APPLICATION_LOG.debug("started using Application Logginng");
System.out.println("Guru");
}

}


WARNING:

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






1) Copied log4j.properties into the src folder which is as below:

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

M
Replied on 04/02/2016

it can be ignored.


M
Replied on 05/02/2016

Hi Support team,

I think it is still not ok, coz the application.log file is not being generated. Please look into the issue again.

Regards
Guru


M
Replied on 05/02/2016

correct the path

D[color=#FF0000:1uiprdvl]\:\\[/color:1uiprdvl]Selenium Udemy\\Selenium\\Application.log


M
Replied on 05/02/2016

Hi Support TEam ,

There is no difference between the path you have mentioned and the pasth that I have used in the code, please recheck

Regards
Guru


M
Replied on 05/02/2016

i marked it red

use this.
D:\\Selenium\\Application.log


M
Replied on 06/02/2016

Hi Support team ,

it works now, but the problem is that all the log messages are appearing twice as shown below.

Log:
06/02/2016 23:14:15 devpinoyLogger started using Application Logginng - NEW TEST
06/02/2016 23:14:15 devpinoyLogger started using Application Logginng - NEW TEST
06/02/2016 23:14:15 devpinoyLogger Finished using Application Logginng - NEW TEST
06/02/2016 23:14:15 devpinoyLogger Finished using Application Logginng - NEW TEST


Code:

package LearningTestNG;

import org.apache.log4j.Logger;
import org.testng.annotations.Test;

public class testlog4j {

public static Logger APPLICATION_LOG = Logger.getLogger("devpinoyLogger");

@Test
public void Test4j(){

APPLICATION_LOG.debug("started using Application Logginng - NEW TEST");
System.out.println("Guru");
APPLICATION_LOG.debug("Finished using Application Logginng - NEW TEST");
}
}


M
Replied on 07/02/2016

weird, see if the test are running twice.


M
Replied on 07/02/2016

that is the only test that I'm executing


M
Replied on 07/02/2016

send the project. i look into it.