geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeremy Boynes <jboy...@gluecode.com>
Subject Re: Logging problems
Date Tue, 09 Nov 2004 19:40:48 GMT
Dain Sundstrom wrote:
> 
> As of an IoCish solution.... If we changed our components to declare a 
> dependency on a Log, the kernel can initialize a log and inject it into 
> the component.  For example, instead of a component using this code to 
> get a log:
> 
> public class MyService {
>     private static final Log log = LogFactory.getLog(MyService.class);
> 
>     public MyService() {
>         log.info("Blah");
>     }
> }
> 
> You do this:
> 
> public class MyService {
>     private final Log log;
> 
>     public MyService(Log log) {
>         this.log = log;
>         log.info("Blah");
>     }
> }
> 
> The key here is code is not directly accessing a LogFactory.  This 
> allows us to provide a log implementation that connects to any log 
> framework.  It also allows the container add additional information to 
> the log events under the covers of the interface, such as the object 
> name of the component.
> 

This seems really cool for GBeans. I have a vague concern the name in 
the log file would be long (especially for 77 objects) making it hard to 
read in vi but on the other hand it would be good to be able to 
differentiate between different GBeans.

We would need to provide a solution though for things that aren't 
GBeans. Perhaps a way that a GBean could create a "child" logger of the 
one it had that it could inject into other things and recursively down?

--
Jeremy

Mime
View raw message