Re: Logging Strategy/best practice



Lord0 wrote:
Hi there,

I am working on a startup J2EE project: JBoss, Spring, Hibernate etc.
One of my responsibilities is to set up the "logging".

I have chosen to use log4j, or more precisely was nudged in that
direction. I've used it before on smaller projects with no problems;
basically a log4j.properties file defining various categories,
appenders and layouts. This approach seems a bit shallow for a larger
project i.e. 100s+ of classes - maybe I'm wrong.....

That depends on how your loggers are used.

Keep in mind that you can configure loggers at the "package" level. That is, you can set the logging for com.xyz.abc.def to INFO and that applies to all loggers of the form com.xyz.abc.def.*.


Questions:

1. Is log4j a suitable solution for this environment?

Of course.

2. Any URLs for logging best practices/patterns. Here I am thinking
about something more involved than a "Log4j 101" article.

http://logging.apache.org

The founder of log4j has written a book that serves as a manual. You should be able to find it from the Apache site.

You may also want to join the log4j-users mailing list, also available from the Apache site.

3. Anything else I should consider?

Use the XML format for the properties file, not the .properties format.


Cheers for yer time

Lord0


HTH, Ray

--
XML is the programmer's duct tape.
.



Relevant Pages

  • Error loading log4j properties file
    ... I am using log4j for logging, ... HOWEVER, if I restart tomcat, everything works fine, I get no errors, ... log4j:ERROR Could not read configuration file from URL ... log4j:WARN Please initialize the log4j system properly. ...
    (comp.lang.java.programmer)
  • Logging APIs
    ... I'm familiar with Log4J, I've read about Java 1.4 Logging, used ... Commons logging to sit on top of Log4J (and read an interesting ... the Avalon logging API. ...
    (comp.lang.java.programmer)
  • log4j vs. java 1.4 logging performance
    ... but OptimizeIt (Borland's code profiler) complains that ... log4j is creating too many strings. ... This problem occurs when I turn logging ...
    (comp.lang.java.programmer)
  • Re: Current thinking on logging?
    ... I have found quite a bit on the web discussing Log4j vs JDK logging vs Commons Logging. ... Everything I read says log4j is better, but we ship a commercial app, and I really don't want to include yet another .jar file. ...
    (comp.lang.java.programmer)
  • Re: log4j vs. java 1.4 logging performance
    ... > log4j is creating too many strings. ... > logging to it's lowest levels. ... To avoid the parameter construction cost write: ...
    (comp.lang.java.programmer)