Sri Sankaran wrote:
-----Original Message-----
From: Matt Raible [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 06, 2002 1:34 PM
To: [EMAIL PROTECTED]
Subject: Best Practices for Logging?
I'm wondering what is considered the best practice for logging using
commons-logging in a Struts app. My current approach is to
have a Base
class in every package that has the following:
protected Log log =
LogFactory.getLog("my.package.name");
But I've noticed that some of the Struts examples have an instance of
this in every class.
Personally I prefer the class level. This provides you with a finer grain of control. However, I restrict it to only one per class and not one per object
public class Foo {
private static Log log = LogFactory.getLog(Foo.class);
..
}
General consensus seems to be that this is the "best practice" approach.
You wind up with more loggers, but they give you very fine-grained
control as Sri mentioned. You can still set a log-level for a package,
but you then also have the ability to manipulate the log-level on a per
class basis too - so you can relaly "zoom-in" on things.
Is this recommended, so that logging
can be done
on a class level, as well as a package level? Any thoughts/opinions
are appreciated.
It should be a static member as per what Sri shows (so you only have one
per class). Yes - it's so you can control logging on a package/class
basis.
Thanks,
Matt
Sri
--
Eddie Bush
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>