commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "SPRINGER,IAN (HP-NewJersey,ex1)" <ian_sprin...@hp.com>
Subject RE: [logging] commons-logging and log4.configuration
Date Thu, 27 Mar 2003 20:33:41 GMT
| -----Original Message-----
| From: Steve Downey [mailto:steve.downey@geowealth.com] 
| Sent: Thursday, March 27, 2003 2:44 PM
| To: Jakarta Commons Developers List
| Subject: RE: [logging] commons-logging and log4.configuration
| 
| 
| On Thu, 2003-03-27 at 13:11, SPRINGER,IAN (HP-NewJersey,ex1) wrote:
| > | 
| > | More specifically, commons-logging explicitly declares 
| > | configuration of
| > | the underlying logging implementation to be out of scope.
| > | 
| > | > --Ian
| > | >
| > | 
| > | Craig
| > 
| > 
| > Oh yes, you're right, I forgot to mention that. I think 
| this is a mistake.
| > After all, initialization from a config file is something 
| that all logging
| > impls will have. So a logging abstraction layer should 
| provide methods for
| > abstracting that functionality.
| > 
| > --Ian
| > 
| 
| Commons logging is an abstraction designed for use by library
| components. A library component has no business configuring a logging
| system. That's a concern for the application, and the application
| *should* know what logging system is being used.
| 
| Commons logging is *not* a logging system. It deliberately restricts
| itself to being a facade for the logger object, and providing 
| a factory
| for those facades. It does not include configuration of the logging
| system, or setting logging levels, or any other activity that an
| application needs that a library component doesn't. This isn't an
| accident, it's a design decision. 

The problem we were encountering was when the enclosing application has not
initialized (or maybe it doesn't use Log4J or JDK 1.4 logging, so it never
initializes. In this case, if the lib tries to call LogFactory.getLog()
prior to any underlying log impl being initialized, you get a nast
RuntimeException. This doesn't work out very well, if you generally
initialize your log in each class in a constant declaration, i.e.:

   /** The logger. */
   private static final Log LOG = LogFactory.getLog( AgentController.class
);

In order to catch a runtime exception here, you'd have to move the above
getLog() call into a try/catch in a static init block in every class.

Hence my desire to see the following methods added to LogFactory:

   void initialize();

   void initialize( String config_location );

   boolean isInitialized();

--Ian

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message