CVS: plexus-container-new/src/java/org/apache/plexus/logging/log4j Log4JLoggerManager.java,1.1.1.1,1.2
[email protected] Sat, 31 May 2003 10:20:13 -0500
| Newsgroups | gmane.comp.java.plexus.devel |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/plexus/plexus-container-new/src/java/org/apache/plexus/logging/log4j
In directory eng.werken.com:/tmp/cvs-serv21816/src/java/org/apache/plexus/logging/log4j
Modified Files:
Log4JLoggerManager.java
Log Message:
The ConsoleLoggerManager can be configured with a logging threshold
level via the plexus.conf configuration file. This enables a user to
control the level of logging messages displayed on the console. For
example:
<logging>
<implementation>org.apache.plexus.logging.ConsoleLoggerManager</implementation>
<logger>
<threshold>DEBUG</threshold>
</logger>
</logging>
In order to accomodate the change, the LoggerManagerFactory, which calls
configure() on a specific LoggerManager, now passes only the <logging>
configuration block instead of the full plexus.conf configuration block.
This makes more sense because each implementation of a LoggerManager no
longer has to take the extra step of conf.getChild("logging").
On a side note, my primary goal is to enhance the logging system so each
component can specify its own logging level. However, I have not gone
through all of the plexus code to start making these changes. I'm
slowly making my way through. My initial thoughts are:
- Add a <logging> block which could contain a logger-specific
configuration. This block would then used by the LoggerManager when
creating the Logger for this component.
For example:
<component>
<role>org.apache.plexus.examples.simple.HelloWorld</role>
<implementation>org.apache.plexus.examples.simple.DefaultHelloWorld</implementation>
<logging>
<priority>DEBUG</priority>
</logging>
<configuration>
<greeting>Hello World!</greeting>
</configuration>
</component>
The above <logging> block might be suitable for use with the
ConsoleLogger or Log4JLogger. In another example, lets say I have a
SylogLogger, perhaps its logging configuration block could take a
ipaddress of where the messages should be logged.
<component>
<role>org.apache.plexus.examples.simple.HelloWorld</role>
<implementation>org.apache.plexus.examples.simple.DefaultHelloWorld</implementation>
<logging>
<priority>DEBUG</priority>
<ipaddress>10.10.10.10</ipaddress>
</logging>
<configuration>
<greeting>Hello World!</greeting>
</configuration>
</component>
One last example, one could specify the Log4J appender to use (assuming
the appenders were defined up top in the logger manager configuration
block), here is a full plexus conf example:
<plexus>
<logging>
<logger>
<appender-id>default</appender-id>
<priority>INFO</priority>
</logger>
<appender>
<id>default</id>
<type>file</type>
<type-configuration>
<file>${plexus.home}/logs/plexus.log</file>
<append>true</append>
</type-configuration>
<threshold>INFO</threshold>
<layout>pattern-layout</layout>
<conversion-pattern>%-4r [%t] %-5p %c %x - %m%n</conversion-pattern>
</appender>
</logging>
<component>
<role>org.apache.plexus.examples.simple.HelloWorld</role>
<implementation>org.apache.plexus.examples.simple.DefaultHelloWorld</implementation>
<logging>
<priority>DEBUG</priority>
<appender-id>default</appender-id>
</logging>
<configuration>
<greeting>Hello World!</greeting>
</configuration>
</component>
</plexus>
Basically, in a nutshell, the <logging> block of the component
descriptor could be used in a LoggerManager-specific manner when
creating Loggers for components.
Just some thoughts of what I am going to be working towards. Does this
seem reasonable?
Index: Log4JLoggerManager.java
===================================================================
RCS file: /cvsroot/plexus/plexus-container-new/src/java/org/apache/plexus/logging/log4j/Log4JLoggerManager.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- Log4JLoggerManager.java 29 Mar 2003 03:49:44 -0000 1.1.1.1
+++ Log4JLoggerManager.java 31 May 2003 15:20:11 -0000 1.2
@@ -102,9 +102,6 @@
extends AbstractLoggerManager
implements Configurable, Initializable, Startable
{
- /** */
- public static final String LOGGING_TAG = "logging";
-
// Sink tags.
/** */
@@ -182,8 +179,8 @@
public void configure( Configuration configuration )
throws ConfigurationException
{
- appenderConfigurations = configuration.getChild( LOGGING_TAG ).getChildren( SINK_TAG );
- loggerConfigurations = configuration.getChild( LOGGING_TAG ).getChildren( LOGGER_TAG );
+ appenderConfigurations = configuration.getChildren( SINK_TAG );
+ loggerConfigurations = configuration.getChildren( LOGGER_TAG );
}
/** @see Initializable#initialize */