aspose file tools*
The moose likes Java in General and the fly likes issue with logging!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "issue with logging!!" Watch "issue with logging!!" New topic
Author

issue with logging!!

sneha krishna
Greenhorn

Joined: Nov 29, 2011
Posts: 7
I have a java class that should generate .csv file named qcCoverageReport.csv and store the test results. But my java class is generating the file but not storing the log. Where have I done the mistake? This is my log4j.properties file:

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern =%d{ABSOLUTE} %5p %c{1}:%L - %m%n
log4j.appender.stdout=org.apache.log4j.DailyRollingFileAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern =%5p (%F:%L) [%d] - %m%n
log4j.appender.stdout.File=C:\\junit\\qcCoverageReport.csv
log4j.rootLogger=INFO, stdout
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Have you appended the appender to the logger?

sneha krishna
Greenhorn

Joined: Nov 29, 2011
Posts: 7
Yes, I have appended
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
I see that you have the log file set below

Hope you have the property configurator to set the configurations...

No need to append a new appender. And check if you are logging against the specified INFO level.
sneha krishna
Greenhorn

Joined: Nov 29, 2011
Posts: 7
Can you please tell me how to configure the PropertyConfigurator class?
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Import the class like below and add the line I posted above to the method where you set your logging. Replace with your log4j property file path.


sneha krishna
Greenhorn

Joined: Nov 29, 2011
Posts: 7
Yes, I have updated the path. But still it is generating an empty file.
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Posting your log configuration and sample logging code might get you better help.
sneha krishna
Greenhorn

Joined: Nov 29, 2011
Posts: 7
This is my class:

John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
Please UseCodeTags and try writing SSCCE

I wrote a sample Junit class and was able to get the log file generated with the properties. I ran in Eclipse -> Run as Junit test. So how do you run yours?



MyLog4j.properties

Good luck..
sneha krishna
Greenhorn

Joined: Nov 29, 2011
Posts: 7
I am running my tests from command prompt. I have added junit.jar in my classpath.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: issue with logging!!