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:
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
The article was really nice. Its all one needs to get start with log4j.
Thanks
11:34 AM
catch (Exception e){
log.error("Error"), e);
}
will also work with log.debug, etc.
12:02 PM
} 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