Error when creating log file | Selenium Forum
M
Posted on 31/03/2016
in module7, part 3 video toward the end where you create log file, i'm getting below error. How to fix it?

M
Replied on 01/04/2016

try this log4j.properties and java file

[quote:egqtqryd]#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
[/quote:egqtqryd]


[quote:egqtqryd]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:egqtqryd]


M
Replied on 01/04/2016

getting same error as mentioned in original post:

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

how to fix this error? -- i have same log4j.properties as you posted in response. Still now working.


M
Replied on 01/04/2016

file path in log4j.properties has to be setup differently.


M
Replied on 04/04/2016

I'm getting the same error. I'm using a mac and below is my log4j file:
How to set up correct file path?

#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=Users/tu//Documents//tmp//Test.log
#do not append the old file. Create a new log file everytime
log4j.appender.dest1.Append=false


M
Replied on 04/04/2016

try this

[quote:10iiexg9]log4j.appender.dest1.File=/Users/tu/Documents/tmp/Test.log
[/quote:10iiexg9]


M
Replied on 06/04/2016

I tried your suggestion and still getting exact same error. Do you have other solution?


M
Replied on 06/04/2016

you're not getting an error you are getting a warning. you can ignore them the warming but please check if log file is been made?


M
Replied on 06/04/2016

I have following in my file and even after applying the changes you gave it is not working:

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


--Can you please provide some help? If needed can we get this resolved via skype session.


M
Replied on 06/04/2016

there is no log file created at all. Can you Please help me figure this out some how?


M
Replied on 07/04/2016

yuri,

first learn it on windows then revert back to mac


M
Replied on 07/04/2016

RS, start a new thread.


M
Replied on 15/04/2016

I also got same issue in window and I found the solution below:

click on the "Run" menu at the top of Eclipse and click on the following:

Run>Run Configurations>Classpath (tab)>User Entries>Advanced (button on the right)>Add Folders>then navigate to the folder that contains your log4j.properties file>Apply>Run


M
Replied on 16/04/2016

its a warning it will remain the same no matter what the error.

if you are on windows zip and send me the project.


M
Replied on 19/04/2016

Run it like below and log file will be created. I also dont have any warning when i run it like this.
click on the "Run" menu at the top of Eclipse and click on the following:
Run >Run Configurations >Classpath (tab) >User Entries > Advanced (button on the right) > Add Folders
then navigate to the folder that contains your log4j.properties file (config folder) >Apply >Run


M
Replied on 20/04/2016

ping me on skype. my skype id is "qtpselenium1"