-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
6.0.0.Final
-
None
The JBoss 6 BridgeLogger is missing some functionality of the log4j Logger class that our app needs to dynamically reconfigure the logger. We need this primarily because we want to send error logging to only an error appender if tracing if off and, if tracing is on, we want to send error logging to both an error appender and also to the trace appender. The idea is that the error log always only shows errors and that the trace log will show both tracing and errors.
To make this work programmatically we use the Logger getAllAppenders, getAppender, setAppender, removeAppender and setLevel calls. Unfortunately, only the setLevel call seems to work in the current BridgeLogger implementation and the other methods apparently do nothing.
Although we are using the log4j API, it might be helpful to illustrate the configuration in jboss-logging.xml terms. We want to be able to set up a configuration that is effectively like this if tracing is off:
<logger category="errors"> <handlers> <handler-ref name="CONSOLE"/> <handler-ref name="ERROR"/> </handlers> </logger> <logger category="tracing"> <level name="OFF"/> <handlers> <handler-ref name="TRACING"/> </handlers> </logger>
So if tracing is turned off, the error logger goes to the error appender/handler and the console.
However, if tracing is turned on. We want to dynamically set to something like this (again this is in effective jboss-logging.xml terms... we actually do make the changes using the log4j API):
<logger category="errors"> <handlers> <handler-ref name="CONSOLE"/> <handler-ref name="ERROR"/> <handler-ref name="TRACING"/> </handlers> </logger> <logger category="tracing"> <level name="DEBUG"/> <handlers> <handler-ref name="TRACING"/> </handlers> </logger>
The difference is that now the error logger now has a new appender/handler for TRACING which wasn't there for the tracing off case. Also the tracing logger is now set to level DEBUG.