| Author |
How to log statements using log4j in file and console with different log levels?
|
Vaman Kulkarni
Greenhorn
Joined: Nov 06, 2009
Posts: 6
|
|
Hi all,
I am using log4j for logging in my application. My requirement is to log DEBUG statements in a log file and INFO statements in console.
Here is my sample log4j.properties.
In above file, I set rootLogger to log DEBUG statements in a fileAppender and another logger "com.ptc.v1tool" to log INFO statements in console.
But the log file contains same entries as that in console i.e. log file contains only INFO logs
Can anyone suggest me how to accomplish my requirement?
Thanks.
|
 |
Kim Boone
Greenhorn
Joined: Oct 22, 2009
Posts: 3
|
|
Varun,
I would suggest using an log4j.xml file. There is an excellent tutorial on logging at http://www.laliluna.de/log4j-tutorial.html. This tutorial will walk you thru all of the steps.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
Welcome to JavaRanch
We prefer to keep this "beginning" forum for really easy questions, so I shall move you where the more difficult questions live.
|
 |
Vaman Kulkarni
Greenhorn
Joined: Nov 06, 2009
Posts: 6
|
|
Thanks Kim for your input. Proved very useful for me.
Thanks Ritchie..I would keep that in mind next time before posting.
|
 |
 |
|
|
subject: How to log statements using log4j in file and console with different log levels?
|
|
|