Henning P. Schmiedehausen wrote:
Hi,
another question came up while working on Avalon support in Turbine:
In the current Turbine code, we use constructs like this:
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class Foo
{
private static Log log = LogFactory.getLog(Foo.class);
[...]
}
to acquire loggers for the various classes. This allows the user to
control exactly which classes or packages he wants to see on which
debug level (ATM we support only Log4j with the commons-logging
package).
In Avalon, the logger is set by the managing component, so in the end,
our AvalonComponentService must pass a Logger object as the "root" logger
to the Component Manager for logging purposes.
ATM we simply set up a new Logging category called "avalon" and pass a
logging object to the Manager:
LoggerManager lm = new Log4JLoggerManager();
Logger logger = lm.getLoggerForCategory(AVALON_LOG_CATEGORY);
DefaultRoleManager roles = new DefaultRoleManager();
roles.enableLogging(logger);
ExcaliburComponentManager manager = new ExcaliburComponentManager();
manager.setLoggerManager(lm);
manager.enableLogging(logger);
But now all the messages from the avalon components end up in a single
logging category, called "avalon":
The Avalon viewpoint on logging is a bit different from the class name
based approach common in Commons Logging for one basic reason:
There can be more than one instance of a component that is used in the
system. If you are using multithreading and there is a bug in the code,
then separating the instances into different pools is very important so
that you can ensure that you can reconstruct the proper sequence of events.
As a result all modern Avalon Containers (i.e. Fortress, Merlin, and
Phoenix) allow you to customize the logger category name for the component in
question. Even ECM provides some support for that.
If you are not using one of the three (Fortress and Phoenix are officially
released, while Merlin is not released yet but is functional), then you should
modify your container to allow you to customize your logger categories for
the components.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]