Log4j errors | Selenium Forum
M
Posted on 24/12/2016
hi,
Below errors displayed
log4j:WARN No appenders could be found for logger (devpinoyLogger).
log4j:WARN Please initialize the log4j system properly.

Followed below steps

add log4j.jar
add log4j.properties directly inside the src folder
create the object in the code

after some searching i have added a step //BasicConfigurator.configure();
program got executed but result was displayed on console.pls help me on this.

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

below is the code

public static void main(String[] args) {

//BasicConfigurator.configure();



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");


}

M
Replied on 25/12/2016

use this
[quote:1bpm1w8s]package com.soapuitutorial.propertie;
import org.apache.log4j.Logger;


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
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");
}
}
[/quote:1bpm1w8s]

use this log4j.properties file

[code:1bpm1w8s]


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



[/code:1bpm1w8s]


M
Replied on 29/12/2016

[quote="qtpselenium.supp0rt@gmail.com":2bqflyt8]use this
[quote:2bqflyt8]package com.soapuitutorial.propertie;
import org.apache.log4j.Logger;


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
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");
}
}
[/quote:2bqflyt8]

use this log4j.properties file

[code:2bqflyt8]


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



[/code:2bqflyt8][/quote:2bqflyt8]