I am using Apache Common Logging in Desktop Application.
private static final Log log = LogFactory.getLog(Utils.class);
How can I direct, Apache Common Logging to write to disc log file, when I perform
log.error(null, exp);
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Commons Logging is basically a wrapper around either Java logging (java.util.logging) or the log4j library. You will need to configure whichever underlying library you are using.
In your example, if I was using log4j (and I generally prefer it to the Java logging system), I would use something like:
log4j.logger.com.mypackage.MyClass = ERROR, FILEA
To specify a file to output to.
It would be worthwhile reading an introduction to log4j if you haven’t already.