arminw 2005/11/21 12:17:59
Modified: src/java/org/apache/ojb/broker/util/logging Tag:
OJB_1_0_RELEASE CommonsLoggerImpl.java
Log4jLoggerImpl.java
src/test/org/apache/ojb Tag: OJB_1_0_RELEASE
commons-logging.properties log4j.properties
OJB-logging.properties
Log:
update logging config files, update comments in Logger impl files,
Log4JLoggerImpl minor improvement
Revision Changes Path
No revision
No revision
1.4.2.2 +3 -3
db-ojb/src/java/org/apache/ojb/broker/util/logging/CommonsLoggerImpl.java
Index: CommonsLoggerImpl.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/logging/CommonsLoggerImpl.java,v
retrieving revision 1.4.2.1
retrieving revision 1.4.2.2
diff -u -r1.4.2.1 -r1.4.2.2
--- CommonsLoggerImpl.java 2 Sep 2005 13:26:22 -0000 1.4.2.1
+++ CommonsLoggerImpl.java 21 Nov 2005 20:16:47 -0000 1.4.2.2
@@ -50,8 +50,8 @@
public Log getLog()
{
/*
- arminw: Log is declared 'transient', thus we have to null-check
- this field
+ Logger interface extends Serializable, thus Log field is
+ declared 'transient' and we have to null-check
*/
if(log == null)
{
1.16.2.3 +54 -39
db-ojb/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java
Index: Log4jLoggerImpl.java
===================================================================
RCS file:
/home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java,v
retrieving revision 1.16.2.2
retrieving revision 1.16.2.3
diff -u -r1.16.2.2 -r1.16.2.3
--- Log4jLoggerImpl.java 2 Sep 2005 13:24:52 -0000 1.16.2.2
+++ Log4jLoggerImpl.java 21 Nov 2005 20:16:47 -0000 1.16.2.3
@@ -51,49 +51,54 @@
private transient org.apache.log4j.Logger logger;
private String name;
- /**
- * Helper method to check if log4j is already configured
- */
+ /** Helper method to check if log4j is already configured */
private static synchronized boolean isLog4JConfigured()
{
- if (log4jConfigured)
- return true;
-
- Enumeration en =
org.apache.log4j.Logger.getRootLogger().getAllAppenders();
-
- if (!(en instanceof org.apache.log4j.helpers.NullEnumeration))
- {
- log4jConfigured = true;
- return true;
- }
- else
+ if(!log4jConfigured)
{
- Enumeration cats = LogManager.getCurrentLoggers();
- while (cats.hasMoreElements())
+ Enumeration en =
org.apache.log4j.Logger.getRootLogger().getAllAppenders();
+
+ if (!(en instanceof org.apache.log4j.helpers.NullEnumeration))
+ {
+ log4jConfigured = true;
+ }
+ else
{
- org.apache.log4j.Logger c = (org.apache.log4j.Logger)
cats.nextElement();
- if (!(c.getAllAppenders() instanceof
org.apache.log4j.helpers.NullEnumeration))
+ Enumeration cats = LogManager.getCurrentLoggers();
+ while (cats.hasMoreElements())
{
- log4jConfigured = true;
- return true;
+ org.apache.log4j.Logger c = (org.apache.log4j.Logger)
cats.nextElement();
+ if (!(c.getAllAppenders() instanceof
org.apache.log4j.helpers.NullEnumeration))
+ {
+ log4jConfigured = true;
+ }
}
}
+ if(log4jConfigured)
+ {
+ String msg = "Log4J is already configured, will not search
for log4j properties file";
+ LoggerFactory.getBootLogger().info(msg);
+ }
+ else
+ {
+ LoggerFactory.getBootLogger().info("Log4J is not
configured");
+ }
}
- return false;
+ return log4jConfigured;
}
/**
* Initialization of log4j <br>
* <b>NOTE</b> - if log4j property file is called log4j.properties then
* log4j will be configured already.
- *
*/
private static synchronized void initializeLog4JSubSystem(String
configFile)
{
- LoggerFactory.getBootLogger().info("Initializing Log4J using file:"
+ configFile);
+ LoggerFactory.getBootLogger().info("Initializing Log4J using file:
'" + configFile + "'");
if(configFile == null || "".equals(configFile.trim()))
{
// no configuration available
+ LoggerFactory.getBootLogger().warn("No log4j configuration file
specified");
}
else
{
@@ -110,20 +115,38 @@
PropertyConfigurator.configure(configFile);
}
}
+ log4jConfigured = true;
}
public Log4jLoggerImpl(String name)
{
this.name = name;
- logger = org.apache.log4j.Logger.getLogger(name);
}
- /**
+ /**
+ * @see
org.apache.ojb.broker.util.configuration.Configurable#configure(Configuration)
+ * This method must be performed by LogFactory after creating a logger
instance.
+ */
+ public void configure(Configuration config) throws
ConfigurationException
+ {
+ if (!isLog4JConfigured())
+ {
+ LoggingConfiguration lc = (LoggingConfiguration) config;
+ initializeLog4JSubSystem(lc.getLoggerConfigFile());
+ }
+ }
+
+ /**
* Gets the logger.
+ *
* @return Returns a Category
*/
private org.apache.log4j.Logger getLogger()
{
+ /*
+ Logger interface extends Serializable, thus Log field is
+ declared 'transient' and we have to null-check
+ */
if (logger == null)
{
logger = org.apache.log4j.Logger.getLogger(name);
@@ -143,6 +166,7 @@
/**
* generate a message for loglevel DEBUG
+ *
* @param pObject the message Object
*/
public final void debug(Object pObject)
@@ -152,6 +176,7 @@
/**
* generate a message for loglevel INFO
+ *
* @param pObject the message Object
*/
public final void info(Object pObject)
@@ -161,6 +186,7 @@
/**
* generate a message for loglevel WARN
+ *
* @param pObject the message Object
*/
public final void warn(Object pObject)
@@ -170,6 +196,7 @@
/**
* generate a message for loglevel ERROR
+ *
* @param pObject the message Object
*/
public final void error(Object pObject)
@@ -179,6 +206,7 @@
/**
* generate a message for loglevel FATAL
+ *
* @param pObject the message Object
*/
public final void fatal(Object pObject)
@@ -411,17 +439,4 @@
}
return false;
}
-
- /**
- * @see
org.apache.ojb.broker.util.configuration.Configurable#configure(Configuration)
- */
- public void configure(Configuration config) throws
ConfigurationException
- {
- if (!isLog4JConfigured())
- {
- LoggingConfiguration lc = (LoggingConfiguration) config;
- initializeLog4JSubSystem(lc.getLoggerConfigFile());
- }
- }
-
}
No revision
No revision
1.2.2.1 +18 -3 db-ojb/src/test/org/apache/ojb/commons-logging.properties
Index: commons-logging.properties
===================================================================
RCS file:
/home/cvs/db-ojb/src/test/org/apache/ojb/commons-logging.properties,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1
--- commons-logging.properties 5 Apr 2004 13:58:59 -0000 1.2
+++ commons-logging.properties 21 Nov 2005 20:16:48 -0000 1.2.2.1
@@ -16,8 +16,23 @@
#-->
#
# commons-logging config
+# -----------------------
+# here can be specified which LogFactory and Log implementation
+# should be used by commons-logging. If none specified or this
+# file isn't in classpath, commons-logging use the default
+# discovery process to determine what type of Log implementation it
+# should use (see commons-logging documentation).
#
-
-org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
-org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
+#org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.LogFactoryImpl
+#
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.AvalonLogger
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.LogKitLogger
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
+# commons-logging version <1.1
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
+# commons-logging version >=1.1
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4J13Logger
+#org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4J12Logger
1.6.2.2 +11 -5 db-ojb/src/test/org/apache/ojb/log4j.properties
Index: log4j.properties
===================================================================
RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/log4j.properties,v
retrieving revision 1.6.2.1
retrieving revision 1.6.2.2
diff -u -r1.6.2.1 -r1.6.2.2
--- log4j.properties 17 Nov 2005 01:34:20 -0000 1.6.2.1
+++ log4j.properties 21 Nov 2005 20:16:48 -0000 1.6.2.2
@@ -16,17 +16,17 @@
#-->
# An example log4j configuration file that outputs both to System.out
# and a file named 'org.apache.ojb.log'.
-
+#
# For the general syntax of property based configuration files see the
# documenation of org.apache.log4j.PropertyConfigurator.
-
+#
# WARNING: Location information can be useful but is very costly in
# terms of computation.
-
+#
# The root category uses the appenders called A1 and A2. Since no
# priority is set, the root category assumes the default which is
# DEBUG
-
+#
log4j.rootCategory=WARN, A1, A2
#
# The boot log level used to initialize logging
@@ -95,6 +95,13 @@
log4j.logger.org.apache.ojb.odmg.ObjectEnvelopeOrdering=WARN
log4j.logger.org.apache.ojb.odmg.LocalTxManager=WARN
log4j.logger.org.apache.ojb.odmg.JTATxManager=WARN
+#
+# Special Logger categories used in test suite
+#
+# Logger for the performance tests
+log4j.logger.performance=INFO
+# Logger for the failover tests
+log4j.logger.failover=INFO
# A1 is set to be ConsoleAppender sending its output to System.out
@@ -128,4 +135,3 @@
-
1.1.2.8 +14 -15 db-ojb/src/test/org/apache/ojb/OJB-logging.properties
Index: OJB-logging.properties
===================================================================
RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/OJB-logging.properties,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- OJB-logging.properties 17 Nov 2005 01:34:20 -0000 1.1.2.7
+++ OJB-logging.properties 21 Nov 2005 20:16:48 -0000 1.1.2.8
@@ -14,13 +14,11 @@
# * limitations under the License.
# */
#-->
+#
# OJB-logging.properties -- configuration of the logging within the OJB
runtime environment
-# Version: 1.0
-# (c) 2001, 2002, 2003 Apache Software Foundation
-# Author: Thomas Mahler and many others
# @version $Id$
#----------------------------------------------------------------------------------------
-# The LoggerClass entry tells OJB which concrete Logger implementation is to
be used.
+# The 'LoggerClass' entry tells OJB which concrete Logger implementation is
to be used.
# If it is not specified (or this file is not present/found, then OJB will
check
# whether there is a log4j.properties or commons-logging.properties file, in
which
# case it will use Log4J/commons-logging. If neither is present, then OJB
will default
@@ -28,12 +26,19 @@
#
# Commons-logging
#LoggerClass=org.apache.ojb.broker.util.logging.CommonsLoggerImpl
+#
# log4j based logging
#LoggerClass=org.apache.ojb.broker.util.logging.Log4jLoggerImpl
+# specifiy the name of log4j properties file (only needed if file
+# name is different from "log4j.properties")
+#LoggerConfigFile=log4j.properties
+#
# OJB's own simple looging support
LoggerClass=org.apache.ojb.broker.util.logging.PoorMansLoggerImpl
-LoggerConfigFile=log4j.properties
#
+#----------------------------------------------------------------
+# all following properties are specific to PoorMansLoggerImpl
+#----------------------------------------------------------------
# The LogLevel entries tells OJB which LogLevels are active
# for the different loggers used within OJB
# Loglevels: DEBUG < INFO < WARN < ERROR < FATAL
@@ -112,18 +117,12 @@
org.apache.ojb.odmg.JTATxManager.LogLevel=WARN
#
#
-# Special Logger categories used in test suite and tutorials
+# Special Logger categories used in test suite
#
-# Logger for the ODMG Implementation
-ODMG.LogLevel=WARN
-# Logger for the JDO RI Implementation
-JDO.LogLevel=INFO
# Logger for the performance tests
performance.LogLevel=INFO
-# Logger for the soda api
-soda.LogLevel=WARN
-# Logger for the factory service
-ConfigurableFactory.LogLevel=WARN
+# Logger for the failover tests
+failover.LogLevel=INFO
#
#
#----------------------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]