You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by Michael Becke <be...@u.washington.edu> on 2003/12/05 20:38:09 UTC
[OJB] Issue #OJB220 - Log4j jar is required at runtime even if not used.
You can view the issue detail at the following URL:
http://nagoya.apache.org/scarab/issues/id/OJB220
Type
Patch
Issue ID
OJB220 (Log4j jar is required at runtime even if not used.)
Reported by
Michael Becke
becke@u.washington.edu (becke@u.washington.edu)
New issue details:
---------------------------------------------------------
Summary set to "Log4j jar is required at runti..."
Description set to "LoggerFactoryImpl requires Log..."
Operating system set to "All"
Issue created
Platform set to "All"
---------------------------------------------------------
This message is automatically generated by the Scarab
issue tracking system. For more information:
http://scarab.tigris.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: [OJB] Issue #OJB220 - Log4j jar is required at runtime even if
not used.
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi mike,
i could apply the patch in eclipse.
thanks
jakob
Michael Becke wrote:
> Hi Jakob,
>
> The patch will apply in Eclipse (in 2.1 at least) if you select the
> org.apache.ojb.broker.util.logging package and then select Team->Apply
> Patch. Please let me know if this does not work, and I will resend.
>
> Thanks,
>
> Mike
>
> Jakob Braeuchi wrote:
>
>> hi michael,
>>
>> eclipse does not like patches affecting multiple files. please post a
>> patch for each file.
>>
>> thanks
>> jakob
>>
>> Michael Becke wrote:
>>
>>> I can't figure out how to attach a patch to an existing issue in
>>> Scarab, so here it is instead. This patch just moves all of the
>>> Log4j code into Log4jLoggerImpl.
>>>
>>> Thanks,
>>>
>>> Mike
>>>
>>>
>>>
>>> Michael Becke wrote:
>>>
>>>> You can view the issue detail at the following URL:
>>>>
>>>> http://nagoya.apache.org/scarab/issues/id/OJB220
>>>>
>>>> Type
>>>> Patch
>>>>
>>>> Issue ID
>>>> OJB220 (Log4j jar is required at runtime even if not used.)
>>>>
>>>> Reported by
>>>> Michael Becke
>>>> becke@u.washington.edu (becke@u.washington.edu)
>>>>
>>>> New issue details:
>>>> ---------------------------------------------------------
>>>>
>>>> Summary set to "Log4j jar is required at runti..."
>>>> Description set to "LoggerFactoryImpl requires Log..."
>>>> Operating system set to "All"
>>>> Issue created
>>>> Platform set to "All"
>>>>
>>>> ---------------------------------------------------------
>>>> This message is automatically generated by the Scarab
>>>> issue tracking system. For more information:
>>>> http://scarab.tigris.org/
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> Index: Log4jLoggerImpl.java
>>> ===================================================================
>>> RCS file:
>>> /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java,v
>>>
>>> retrieving revision 1.11
>>> diff -u -r1.11 Log4jLoggerImpl.java
>>> --- Log4jLoggerImpl.java 13 Mar 2003 19:56:33 -0000 1.11
>>> +++ Log4jLoggerImpl.java 5 Dec 2003 19:12:03 -0000
>>> @@ -54,9 +54,13 @@
>>> * <http://www.apache.org/>.
>>> */
>>>
>>> +import java.net.URL;
>>> +import java.util.Enumeration;
>>> import java.util.HashMap;
>>>
>>> +import org.apache.log4j.LogManager;
>>> import org.apache.log4j.Priority;
>>> +import org.apache.log4j.PropertyConfigurator;
>>> import org.apache.ojb.broker.util.configuration.Configuration;
>>> import org.apache.ojb.broker.util.configuration.ConfigurationException;
>>>
>>> @@ -85,6 +89,9 @@
>>>
>>> static private final String FQCN = Log4jLoggerImpl.class.getName();
>>>
>>> + /** flag about log4j configuration state */
>>> + private static boolean log4jConfigured = false;
>>> +
>>> static {
>>> priorityMap = new HashMap();
>>> priorityMap.put(new Integer(Logger.DEBUG), Priority.DEBUG);
>>> @@ -94,6 +101,72 @@
>>> priorityMap.put(new Integer(Logger.FATAL), Priority.FATAL);
>>> }
>>>
>>> + /**
>>> + * Helper method to check if log4j is already configured
>>> + */
>>> + private static synchronized boolean isLog4JConfigured()
>>> + {
>>> + if (log4jConfigured)
>>> + return true;
>>> +
>>> + Enumeration enum =
>>> org.apache.log4j.Logger.getRootLogger().getAllAppenders();
>>> +
>>> + if (!(enum instanceof
>>> org.apache.log4j.helpers.NullEnumeration))
>>> + {
>>> + log4jConfigured = true;
>>> + return true;
>>> + }
>>> + else
>>> + {
>>> + Enumeration cats = LogManager.getCurrentLoggers();
>>> + while (cats.hasMoreElements())
>>> + {
>>> + org.apache.log4j.Logger c =
>>> (org.apache.log4j.Logger) cats.nextElement();
>>> + if (!(c.getAllAppenders() instanceof
>>> org.apache.log4j.helpers.NullEnumeration))
>>> + {
>>> + log4jConfigured = true;
>>> + return true;
>>> + }
>>> + }
>>> + }
>>> + return false;
>>> + }
>>> +
>>> + /**
>>> + * 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);
>>> + if (configFile != null)
>>> + {
>>> + // try resource look in classpath
>>> + URL url =
>>> Thread.currentThread().getContextClassLoader().getResource(configFile);
>>> + LoggerFactory.getBootLogger().info("Initializing Log4J :
>>> resource from config file:" + url);
>>> + if (url != null)
>>> + {
>>> + PropertyConfigurator.configure(url);
>>> + }
>>> +
>>> + // if file is not in classpath try ordinary filesystem
>>> lookup
>>> + else if (configFile != "")
>>> + {
>>> + PropertyConfigurator.configure(configFile);
>>> + }
>>> + else
>>> + {
>>> + // no configuration available
>>> + }
>>> + }
>>> + else
>>> + {
>>> + // no configuration available
>>> + }
>>> + }
>>> +
>>> public Log4jLoggerImpl(String name)
>>> {
>>> this.name = name;
>>> @@ -386,13 +459,15 @@
>>> }
>>>
>>> /**
>>> - * This impl just throws UnsupporteOperationException because
>>> Log4j logger have a centrilized configuration/initialization system
>>> - *
>>> * @see
>>> org.apache.ojb.broker.util.configuration.Configurable#configure(Configuration)
>>>
>>> */
>>> public void configure(Configuration config) throws
>>> ConfigurationException
>>> {
>>> - throw new UnsupportedOperationException("Log4j loggers can't
>>> be individually initialized !");
>>> + if (!isLog4JConfigured())
>>> + {
>>> + LoggingConfiguration lc = (LoggingConfiguration) config;
>>> + initializeLog4JSubSystem(lc.getLoggerConfigFile());
>>> + }
>>> }
>>>
>>> }
>>> Index: LoggerFactoryImpl.java
>>> ===================================================================
>>> RCS file:
>>> /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/util/logging/LoggerFactoryImpl.java,v
>>>
>>> retrieving revision 1.11
>>> diff -u -r1.11 LoggerFactoryImpl.java
>>> --- LoggerFactoryImpl.java 6 Mar 2003 14:41:46 -0000 1.11
>>> +++ LoggerFactoryImpl.java 5 Dec 2003 19:12:04 -0000
>>> @@ -56,17 +56,13 @@
>>>
>>> //OJB
>>>
>>> -import org.apache.log4j.LogManager;
>>> -import org.apache.log4j.PropertyConfigurator;
>>> +import java.util.HashMap;
>>> +import java.util.Map;
>>> +
>>> import org.apache.ojb.broker.util.ClassHelper;
>>> import org.apache.ojb.broker.util.configuration.Configurator;
>>> import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
>>>
>>> -import java.net.URL;
>>> -import java.util.Enumeration;
>>> -import java.util.HashMap;
>>> -import java.util.Map;
>>> -
>>> /**
>>> * The factory class <code>LoggerFactory</code> can be used
>>> * to create <code>Logger</code> instances.
>>> @@ -92,9 +88,6 @@
>>> /** Used for caching logger instances */
>>> Map cache = new HashMap();
>>>
>>> - /** flag about log4j configuration state */
>>> - private boolean log4jConfigured = false;
>>> -
>>> // yes. it's a singleton !
>>> private LoggerFactoryImpl()
>>> {
>>> @@ -187,10 +180,7 @@
>>> if (logger instanceof Log4jLoggerImpl)
>>> {
>>> getBootLogger().debug("Initializing Log4j logger
>>> instance " + loggerName);
>>> - if (!isLog4JConfigured())
>>> - {
>>> - initializeLog4JSubSystem(lc.getLoggerConfigFile());
>>> - }
>>> + logger.configure(lc);
>>> }
>>> else if (logger instanceof PoorMansLoggerImpl)
>>> {
>>> @@ -226,74 +216,6 @@
>>> logger.error("[" + this.getClass().getName() + "]
>>> Could not set logger for class " + loggerClass, t);
>>> }
>>> return logger;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Helper method to check if log4j is already configured
>>> - */
>>> - synchronized boolean isLog4JConfigured()
>>> - {
>>> - if (log4jConfigured)
>>> - return true;
>>> -
>>> - Enumeration enum =
>>> org.apache.log4j.Logger.getRootLogger().getAllAppenders();
>>> -
>>> - if (!(enum instanceof
>>> org.apache.log4j.helpers.NullEnumeration))
>>> - {
>>> - log4jConfigured = true;
>>> - return true;
>>> - }
>>> - else
>>> - {
>>> - Enumeration cats = LogManager.getCurrentLoggers();
>>> - while (cats.hasMoreElements())
>>> - {
>>> - org.apache.log4j.Logger c =
>>> (org.apache.log4j.Logger) cats.nextElement();
>>> - if (!(c.getAllAppenders() instanceof
>>> org.apache.log4j.helpers.NullEnumeration))
>>> - {
>>> - log4jConfigured = true;
>>> - return true;
>>> - }
>>> - }
>>> - }
>>> - return false;
>>> - }
>>> -
>>> -
>>> - /**
>>> - * Initialization of log4j <br>
>>> - * <b>NOTE</b> - if log4j property file is called
>>> log4j.properties then
>>> - * log4j will be configured already.
>>> - *
>>> - */
>>> - synchronized void initializeLog4JSubSystem(String configFile)
>>> - {
>>> - getBootLogger().info("Initializing Log4J using file:" +
>>> configFile);
>>> - if (configFile != null)
>>> - {
>>> - // try resource look in classpath
>>> - URL url =
>>> Thread.currentThread().getContextClassLoader().getResource(configFile);
>>> - getBootLogger().info("Initializing Log4J : resource from
>>> config file:" + url);
>>> - if (url != null)
>>> - {
>>> - PropertyConfigurator.configure(url);
>>> - }
>>> -
>>> - // if file is not in classpath try ordinary filesystem
>>> lookup
>>> - else if (configFile != "")
>>> - {
>>> - PropertyConfigurator.configure(configFile);
>>> - }
>>> - else
>>> - {
>>> - // no configuration available
>>> - }
>>> - }
>>> - else
>>> - {
>>> - // no configuration available
>>> - }
>>> }
>>>
>>> }
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: [OJB] Issue #OJB220 - Log4j jar is required at runtime even if
not used.
Posted by Michael Becke <be...@u.washington.edu>.
Hi Jakob,
The patch will apply in Eclipse (in 2.1 at least) if you select the
org.apache.ojb.broker.util.logging package and then select Team->Apply
Patch. Please let me know if this does not work, and I will resend.
Thanks,
Mike
Jakob Braeuchi wrote:
> hi michael,
>
> eclipse does not like patches affecting multiple files. please post a
> patch for each file.
>
> thanks
> jakob
>
> Michael Becke wrote:
>
>> I can't figure out how to attach a patch to an existing issue in
>> Scarab, so here it is instead. This patch just moves all of the Log4j
>> code into Log4jLoggerImpl.
>>
>> Thanks,
>>
>> Mike
>>
>>
>>
>> Michael Becke wrote:
>>
>>> You can view the issue detail at the following URL:
>>>
>>> http://nagoya.apache.org/scarab/issues/id/OJB220
>>>
>>> Type
>>> Patch
>>>
>>> Issue ID
>>> OJB220 (Log4j jar is required at runtime even if not used.)
>>>
>>> Reported by
>>> Michael Becke
>>> becke@u.washington.edu (becke@u.washington.edu)
>>>
>>> New issue details:
>>> ---------------------------------------------------------
>>>
>>> Summary set to "Log4j jar is required at runti..."
>>> Description set to "LoggerFactoryImpl requires Log..."
>>> Operating system set to "All"
>>> Issue created
>>> Platform set to "All"
>>>
>>> ---------------------------------------------------------
>>> This message is automatically generated by the Scarab
>>> issue tracking system. For more information:
>>> http://scarab.tigris.org/
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>>
>>
>> ------------------------------------------------------------------------
>>
>> Index: Log4jLoggerImpl.java
>> ===================================================================
>> RCS file:
>> /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java,v
>>
>> retrieving revision 1.11
>> diff -u -r1.11 Log4jLoggerImpl.java
>> --- Log4jLoggerImpl.java 13 Mar 2003 19:56:33 -0000 1.11
>> +++ Log4jLoggerImpl.java 5 Dec 2003 19:12:03 -0000
>> @@ -54,9 +54,13 @@
>> * <http://www.apache.org/>.
>> */
>>
>> +import java.net.URL;
>> +import java.util.Enumeration;
>> import java.util.HashMap;
>>
>> +import org.apache.log4j.LogManager;
>> import org.apache.log4j.Priority;
>> +import org.apache.log4j.PropertyConfigurator;
>> import org.apache.ojb.broker.util.configuration.Configuration;
>> import org.apache.ojb.broker.util.configuration.ConfigurationException;
>>
>> @@ -85,6 +89,9 @@
>>
>> static private final String FQCN = Log4jLoggerImpl.class.getName();
>>
>> + /** flag about log4j configuration state */
>> + private static boolean log4jConfigured = false;
>> +
>> static {
>> priorityMap = new HashMap();
>> priorityMap.put(new Integer(Logger.DEBUG), Priority.DEBUG);
>> @@ -94,6 +101,72 @@
>> priorityMap.put(new Integer(Logger.FATAL), Priority.FATAL);
>> }
>>
>> + /**
>> + * Helper method to check if log4j is already configured
>> + */
>> + private static synchronized boolean isLog4JConfigured()
>> + {
>> + if (log4jConfigured)
>> + return true;
>> +
>> + Enumeration enum =
>> org.apache.log4j.Logger.getRootLogger().getAllAppenders();
>> +
>> + if (!(enum instanceof org.apache.log4j.helpers.NullEnumeration))
>> + {
>> + log4jConfigured = true;
>> + return true;
>> + }
>> + else
>> + {
>> + Enumeration cats = LogManager.getCurrentLoggers();
>> + while (cats.hasMoreElements())
>> + {
>> + org.apache.log4j.Logger c = (org.apache.log4j.Logger)
>> cats.nextElement();
>> + if (!(c.getAllAppenders() instanceof
>> org.apache.log4j.helpers.NullEnumeration))
>> + {
>> + log4jConfigured = true;
>> + return true;
>> + }
>> + }
>> + }
>> + return false;
>> + }
>> +
>> + /**
>> + * 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);
>> + if (configFile != null)
>> + {
>> + // try resource look in classpath
>> + URL url =
>> Thread.currentThread().getContextClassLoader().getResource(configFile);
>> + LoggerFactory.getBootLogger().info("Initializing Log4J :
>> resource from config file:" + url);
>> + if (url != null)
>> + {
>> + PropertyConfigurator.configure(url);
>> + }
>> +
>> + // if file is not in classpath try ordinary filesystem
>> lookup
>> + else if (configFile != "")
>> + {
>> + PropertyConfigurator.configure(configFile);
>> + }
>> + else
>> + {
>> + // no configuration available
>> + }
>> + }
>> + else
>> + {
>> + // no configuration available
>> + }
>> + }
>> +
>> public Log4jLoggerImpl(String name)
>> {
>> this.name = name;
>> @@ -386,13 +459,15 @@
>> }
>>
>> /**
>> - * This impl just throws UnsupporteOperationException because
>> Log4j logger have a centrilized configuration/initialization system
>> - *
>> * @see
>> org.apache.ojb.broker.util.configuration.Configurable#configure(Configuration)
>>
>> */
>> public void configure(Configuration config) throws
>> ConfigurationException
>> {
>> - throw new UnsupportedOperationException("Log4j loggers can't
>> be individually initialized !");
>> + if (!isLog4JConfigured())
>> + {
>> + LoggingConfiguration lc = (LoggingConfiguration) config;
>> + initializeLog4JSubSystem(lc.getLoggerConfigFile());
>> + }
>> }
>>
>> }
>> Index: LoggerFactoryImpl.java
>> ===================================================================
>> RCS file:
>> /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/util/logging/LoggerFactoryImpl.java,v
>>
>> retrieving revision 1.11
>> diff -u -r1.11 LoggerFactoryImpl.java
>> --- LoggerFactoryImpl.java 6 Mar 2003 14:41:46 -0000 1.11
>> +++ LoggerFactoryImpl.java 5 Dec 2003 19:12:04 -0000
>> @@ -56,17 +56,13 @@
>>
>> //OJB
>>
>> -import org.apache.log4j.LogManager;
>> -import org.apache.log4j.PropertyConfigurator;
>> +import java.util.HashMap;
>> +import java.util.Map;
>> +
>> import org.apache.ojb.broker.util.ClassHelper;
>> import org.apache.ojb.broker.util.configuration.Configurator;
>> import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
>>
>> -import java.net.URL;
>> -import java.util.Enumeration;
>> -import java.util.HashMap;
>> -import java.util.Map;
>> -
>> /**
>> * The factory class <code>LoggerFactory</code> can be used
>> * to create <code>Logger</code> instances.
>> @@ -92,9 +88,6 @@
>> /** Used for caching logger instances */
>> Map cache = new HashMap();
>>
>> - /** flag about log4j configuration state */
>> - private boolean log4jConfigured = false;
>> -
>> // yes. it's a singleton !
>> private LoggerFactoryImpl()
>> {
>> @@ -187,10 +180,7 @@
>> if (logger instanceof Log4jLoggerImpl)
>> {
>> getBootLogger().debug("Initializing Log4j logger
>> instance " + loggerName);
>> - if (!isLog4JConfigured())
>> - {
>> - initializeLog4JSubSystem(lc.getLoggerConfigFile());
>> - }
>> + logger.configure(lc);
>> }
>> else if (logger instanceof PoorMansLoggerImpl)
>> {
>> @@ -226,74 +216,6 @@
>> logger.error("[" + this.getClass().getName() + "] Could
>> not set logger for class " + loggerClass, t);
>> }
>> return logger;
>> - }
>> -
>> -
>> - /**
>> - * Helper method to check if log4j is already configured
>> - */
>> - synchronized boolean isLog4JConfigured()
>> - {
>> - if (log4jConfigured)
>> - return true;
>> -
>> - Enumeration enum =
>> org.apache.log4j.Logger.getRootLogger().getAllAppenders();
>> -
>> - if (!(enum instanceof org.apache.log4j.helpers.NullEnumeration))
>> - {
>> - log4jConfigured = true;
>> - return true;
>> - }
>> - else
>> - {
>> - Enumeration cats = LogManager.getCurrentLoggers();
>> - while (cats.hasMoreElements())
>> - {
>> - org.apache.log4j.Logger c = (org.apache.log4j.Logger)
>> cats.nextElement();
>> - if (!(c.getAllAppenders() instanceof
>> org.apache.log4j.helpers.NullEnumeration))
>> - {
>> - log4jConfigured = true;
>> - return true;
>> - }
>> - }
>> - }
>> - return false;
>> - }
>> -
>> -
>> - /**
>> - * Initialization of log4j <br>
>> - * <b>NOTE</b> - if log4j property file is called
>> log4j.properties then
>> - * log4j will be configured already.
>> - *
>> - */
>> - synchronized void initializeLog4JSubSystem(String configFile)
>> - {
>> - getBootLogger().info("Initializing Log4J using file:" +
>> configFile);
>> - if (configFile != null)
>> - {
>> - // try resource look in classpath
>> - URL url =
>> Thread.currentThread().getContextClassLoader().getResource(configFile);
>> - getBootLogger().info("Initializing Log4J : resource from
>> config file:" + url);
>> - if (url != null)
>> - {
>> - PropertyConfigurator.configure(url);
>> - }
>> -
>> - // if file is not in classpath try ordinary filesystem
>> lookup
>> - else if (configFile != "")
>> - {
>> - PropertyConfigurator.configure(configFile);
>> - }
>> - else
>> - {
>> - // no configuration available
>> - }
>> - }
>> - else
>> - {
>> - // no configuration available
>> - }
>> }
>>
>> }
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: [OJB] Issue #OJB220 - Log4j jar is required at runtime even if
not used.
Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi michael,
eclipse does not like patches affecting multiple files. please post a
patch for each file.
thanks
jakob
Michael Becke wrote:
> I can't figure out how to attach a patch to an existing issue in Scarab,
> so here it is instead. This patch just moves all of the Log4j code into
> Log4jLoggerImpl.
>
> Thanks,
>
> Mike
>
>
>
> Michael Becke wrote:
>
>> You can view the issue detail at the following URL:
>>
>> http://nagoya.apache.org/scarab/issues/id/OJB220
>>
>> Type
>> Patch
>>
>> Issue ID
>> OJB220 (Log4j jar is required at runtime even if not used.)
>>
>> Reported by
>> Michael Becke
>> becke@u.washington.edu (becke@u.washington.edu)
>>
>> New issue details:
>> ---------------------------------------------------------
>>
>> Summary set to "Log4j jar is required at runti..."
>> Description set to "LoggerFactoryImpl requires Log..."
>> Operating system set to "All"
>> Issue created
>> Platform set to "All"
>>
>> ---------------------------------------------------------
>> This message is automatically generated by the Scarab
>> issue tracking system. For more information:
>> http://scarab.tigris.org/
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
>> For additional commands, e-mail: ojb-dev-help@db.apache.org
>>
>
> ------------------------------------------------------------------------
>
> Index: Log4jLoggerImpl.java
> ===================================================================
> RCS file: /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/util/logging/Log4jLoggerImpl.java,v
> retrieving revision 1.11
> diff -u -r1.11 Log4jLoggerImpl.java
> --- Log4jLoggerImpl.java 13 Mar 2003 19:56:33 -0000 1.11
> +++ Log4jLoggerImpl.java 5 Dec 2003 19:12:03 -0000
> @@ -54,9 +54,13 @@
> * <http://www.apache.org/>.
> */
>
> +import java.net.URL;
> +import java.util.Enumeration;
> import java.util.HashMap;
>
> +import org.apache.log4j.LogManager;
> import org.apache.log4j.Priority;
> +import org.apache.log4j.PropertyConfigurator;
> import org.apache.ojb.broker.util.configuration.Configuration;
> import org.apache.ojb.broker.util.configuration.ConfigurationException;
>
> @@ -85,6 +89,9 @@
>
> static private final String FQCN = Log4jLoggerImpl.class.getName();
>
> + /** flag about log4j configuration state */
> + private static boolean log4jConfigured = false;
> +
> static {
> priorityMap = new HashMap();
> priorityMap.put(new Integer(Logger.DEBUG), Priority.DEBUG);
> @@ -94,6 +101,72 @@
> priorityMap.put(new Integer(Logger.FATAL), Priority.FATAL);
> }
>
> + /**
> + * Helper method to check if log4j is already configured
> + */
> + private static synchronized boolean isLog4JConfigured()
> + {
> + if (log4jConfigured)
> + return true;
> +
> + Enumeration enum = org.apache.log4j.Logger.getRootLogger().getAllAppenders();
> +
> + if (!(enum instanceof org.apache.log4j.helpers.NullEnumeration))
> + {
> + log4jConfigured = true;
> + return true;
> + }
> + else
> + {
> + Enumeration cats = LogManager.getCurrentLoggers();
> + while (cats.hasMoreElements())
> + {
> + org.apache.log4j.Logger c = (org.apache.log4j.Logger) cats.nextElement();
> + if (!(c.getAllAppenders() instanceof org.apache.log4j.helpers.NullEnumeration))
> + {
> + log4jConfigured = true;
> + return true;
> + }
> + }
> + }
> + return false;
> + }
> +
> + /**
> + * 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);
> + if (configFile != null)
> + {
> + // try resource look in classpath
> + URL url = Thread.currentThread().getContextClassLoader().getResource(configFile);
> + LoggerFactory.getBootLogger().info("Initializing Log4J : resource from config file:" + url);
> + if (url != null)
> + {
> + PropertyConfigurator.configure(url);
> + }
> +
> + // if file is not in classpath try ordinary filesystem lookup
> + else if (configFile != "")
> + {
> + PropertyConfigurator.configure(configFile);
> + }
> + else
> + {
> + // no configuration available
> + }
> + }
> + else
> + {
> + // no configuration available
> + }
> + }
> +
> public Log4jLoggerImpl(String name)
> {
> this.name = name;
> @@ -386,13 +459,15 @@
> }
>
> /**
> - * This impl just throws UnsupporteOperationException because Log4j logger have a centrilized configuration/initialization system
> - *
> * @see org.apache.ojb.broker.util.configuration.Configurable#configure(Configuration)
> */
> public void configure(Configuration config) throws ConfigurationException
> {
> - throw new UnsupportedOperationException("Log4j loggers can't be individually initialized !");
> + if (!isLog4JConfigured())
> + {
> + LoggingConfiguration lc = (LoggingConfiguration) config;
> + initializeLog4JSubSystem(lc.getLoggerConfigFile());
> + }
> }
>
> }
> Index: LoggerFactoryImpl.java
> ===================================================================
> RCS file: /home/cvspublic/db-ojb/src/java/org/apache/ojb/broker/util/logging/LoggerFactoryImpl.java,v
> retrieving revision 1.11
> diff -u -r1.11 LoggerFactoryImpl.java
> --- LoggerFactoryImpl.java 6 Mar 2003 14:41:46 -0000 1.11
> +++ LoggerFactoryImpl.java 5 Dec 2003 19:12:04 -0000
> @@ -56,17 +56,13 @@
>
> //OJB
>
> -import org.apache.log4j.LogManager;
> -import org.apache.log4j.PropertyConfigurator;
> +import java.util.HashMap;
> +import java.util.Map;
> +
> import org.apache.ojb.broker.util.ClassHelper;
> import org.apache.ojb.broker.util.configuration.Configurator;
> import org.apache.ojb.broker.util.configuration.impl.OjbConfigurator;
>
> -import java.net.URL;
> -import java.util.Enumeration;
> -import java.util.HashMap;
> -import java.util.Map;
> -
> /**
> * The factory class <code>LoggerFactory</code> can be used
> * to create <code>Logger</code> instances.
> @@ -92,9 +88,6 @@
> /** Used for caching logger instances */
> Map cache = new HashMap();
>
> - /** flag about log4j configuration state */
> - private boolean log4jConfigured = false;
> -
> // yes. it's a singleton !
> private LoggerFactoryImpl()
> {
> @@ -187,10 +180,7 @@
> if (logger instanceof Log4jLoggerImpl)
> {
> getBootLogger().debug("Initializing Log4j logger instance " + loggerName);
> - if (!isLog4JConfigured())
> - {
> - initializeLog4JSubSystem(lc.getLoggerConfigFile());
> - }
> + logger.configure(lc);
> }
> else if (logger instanceof PoorMansLoggerImpl)
> {
> @@ -226,74 +216,6 @@
> logger.error("[" + this.getClass().getName() + "] Could not set logger for class " + loggerClass, t);
> }
> return logger;
> - }
> -
> -
> - /**
> - * Helper method to check if log4j is already configured
> - */
> - synchronized boolean isLog4JConfigured()
> - {
> - if (log4jConfigured)
> - return true;
> -
> - Enumeration enum = org.apache.log4j.Logger.getRootLogger().getAllAppenders();
> -
> - if (!(enum instanceof org.apache.log4j.helpers.NullEnumeration))
> - {
> - log4jConfigured = true;
> - return true;
> - }
> - else
> - {
> - Enumeration cats = LogManager.getCurrentLoggers();
> - while (cats.hasMoreElements())
> - {
> - org.apache.log4j.Logger c = (org.apache.log4j.Logger) cats.nextElement();
> - if (!(c.getAllAppenders() instanceof org.apache.log4j.helpers.NullEnumeration))
> - {
> - log4jConfigured = true;
> - return true;
> - }
> - }
> - }
> - return false;
> - }
> -
> -
> - /**
> - * Initialization of log4j <br>
> - * <b>NOTE</b> - if log4j property file is called log4j.properties then
> - * log4j will be configured already.
> - *
> - */
> - synchronized void initializeLog4JSubSystem(String configFile)
> - {
> - getBootLogger().info("Initializing Log4J using file:" + configFile);
> - if (configFile != null)
> - {
> - // try resource look in classpath
> - URL url = Thread.currentThread().getContextClassLoader().getResource(configFile);
> - getBootLogger().info("Initializing Log4J : resource from config file:" + url);
> - if (url != null)
> - {
> - PropertyConfigurator.configure(url);
> - }
> -
> - // if file is not in classpath try ordinary filesystem lookup
> - else if (configFile != "")
> - {
> - PropertyConfigurator.configure(configFile);
> - }
> - else
> - {
> - // no configuration available
> - }
> - }
> - else
> - {
> - // no configuration available
> - }
> }
>
> }
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org
Re: [OJB] Issue #OJB220 - Log4j jar is required at runtime even if
not used.
Posted by Michael Becke <be...@u.washington.edu>.
I can't figure out how to attach a patch to an existing issue in Scarab,
so here it is instead. This patch just moves all of the Log4j code into
Log4jLoggerImpl.
Thanks,
Mike
Michael Becke wrote:
> You can view the issue detail at the following URL:
>
> http://nagoya.apache.org/scarab/issues/id/OJB220
>
> Type
> Patch
>
> Issue ID
> OJB220 (Log4j jar is required at runtime even if not used.)
>
> Reported by
> Michael Becke
> becke@u.washington.edu (becke@u.washington.edu)
>
> New issue details:
> ---------------------------------------------------------
>
> Summary set to "Log4j jar is required at runti..."
> Description set to "LoggerFactoryImpl requires Log..."
> Operating system set to "All"
> Issue created
> Platform set to "All"
>
> ---------------------------------------------------------
> This message is automatically generated by the Scarab
> issue tracking system. For more information:
> http://scarab.tigris.org/
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>