Below is my log4j.properties file content, file is placed with the src folder in eclipse.
#Application Logs
log4j.rootlogger=INFO, logg
log4j.appender.logg=org.apache.log4j.RollingFileAppender
log4j.appender.logg.File=D:\\SandhyaFiles\\SeleniumWorkspace\\InterviewProject\\Logs\\Testlogs.log
log4j.appender.logg.layout=org.apache.log4j.PatternLayout
log4j.appender.logg.layout.ConversionPattern=%d -%c -%p - %m%n
log4j.appender.logg.maxFileSize=5MB
log4j.appender.logg.maxBackupIndex=3
Inside Library package i have initialised and used logj as below:
public class Library
{
public static final Logger Log = Logger.getLogger(Library.class);
public void initialized(){
Log.info("Inside initialise")
}}
calling initialize from testcase throws log4j warning:
log4j:WARN No appenders could be found for logger (library.Library). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Please Help me fix this.
It seems like log4j is not able to find the log4j properties file.
One could specify the location of the log4j.properties file explicitly via the
log4j.configuration
system property.In case the system property
log4j.configuration
is not defined, then the resource is set to its default valuelog4j.properties
and looked for in the classpath of the project (at root).After so many trials, weirdly re arranging the properties file to this everything is going no warning and could get the logs.
I wonder why this is so? if somebody can explain it will be great help. Thanks