Your daily dose of Java and related technologies.
News, Releases, Reviews, Tutorials, Articles, Events, Contests, Comments, Code and much more.
This java weblog is maintained by Xyling Technologies, making life simpler.

Thursday, April 21, 2005

Build Flexible Logs With log4j

log4j, an Apache Jakarta project, offers unprecedented levels of control over logging. This article (by Vikram Goyal) offers a sample Web application to explain how to use log4j.

[Resource-Type: Tutorial; Category: Java, Logging; XRating: 4]
Refer to the title of this post for the complete tutorial at OnJava

4 Comments:

Anonymous Silent Walker said...

I have been using log4j for quite a while now. Indeed its a great tool.
By the way, do you konw how to printStackTrace() in the log file ?

11:31 AM

 
Anonymous Asif Iqbal said...

The article was really nice. Its all one needs to get start with log4j.

Thanks

11:34 AM

 
Anonymous Anonymous said...

catch (Exception e){
log.error("Error"), e);
}

will also work with log.debug, etc.

12:02 PM

 
Anonymous Anonymous said...

} catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
log.fatal(e.getMessage());
log.fatal(e.getCause().toString());
e.printStackTrace(pw);
log.fatal(sw.toString());
}

12:03 AM

 

Post a Comment

<< Home