User: juhalindfors
Date: 01/04/21 05:21:06
Modified: src/main/org/jboss/logging Log4jService.java
Log:
Patch #417793 -- Use log names for log4j categories.
Submitted By: David Jencks (d_jencks)
Revision Changes Path
1.4 +14 -8 jboss/src/main/org/jboss/logging/Log4jService.java
Index: Log4jService.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/logging/Log4jService.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Log4jService.java 2001/04/13 19:06:59 1.3
+++ Log4jService.java 2001/04/21 12:21:06 1.4
@@ -22,18 +22,23 @@
import org.apache.log4j.NDC;
import org.apache.log4j.PropertyConfigurator;
-/** This is a JMX MBean that provides two features:
+/** This is a JMX MBean that provides three features:
1., It initalizes the log4j framework from the log4j properties format file
specified by the ConfigurationPath attribute to that the log4j may be
used by JBoss components.
2., It collects JMX notification events fired by the "service=Log" mbean
- and logs the msgs to the log4j root Category. This allows the Log4jService
+ and logs the msgs to log4j. This allows the Log4jService
to replace all other JBoss logging services like ConsoleLogging and
FileLogging.
+
+3, It uses the log name as the category to log under, allowing you to turn
+ individual components on and off using the log4j configuration file
+ (automatically reloaded frequently).
@author <a href="mailto:[EMAIL PROTECTED]">Fulco Muriglio</a>
@author [EMAIL PROTECTED]
-@version $Revision: 1.3 $
+@author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a>
+@version $Revision: 1.4 $
*/
public class Log4jService implements Log4jServiceMBean, NotificationListener,
MBeanRegistration
@@ -146,21 +151,22 @@
String source = (String) n.getUserData();
if( source == null || source.length() == 0 )
source = "Default";
-
+ //get a category based on the source name, so we can turn on and off pieces
of logging.
+ Category localCategory = category.getInstance(source);
NDC.push(source);
switch( type )
{
case 'W':
- category.warn(msg);
+ localCategory.warn(msg);
break;
case 'D':
- category.debug(msg);
+ localCategory.debug(msg);
break;
case 'E':
- category.error(msg);
+ localCategory.error(msg);
break;
default:
- category.info(msg);
+ localCategory.info(msg);
break;
}
NDC.pop();
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development