You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-dev@portals.apache.org by "David H. DeWolf" <dd...@apache.org> on 2004/12/23 04:40:26 UTC

Pluto 1.1 Logging (was Re: Dependency injection in Pluto 1.1)

I personally prefer one of two approaches:

1) Dependency Injection against a simple logging interface.

2) Straight use of commons-logging.

The latter (commons-logging) is my preference simply because I find that 
there are very few cases where you don't want SOME sort of logging. 
Passing a logging implementation around to almost everything seems to 
get out of control, and the user of commons-logging allows for a thin 
adapter to whatever implementation is configured.

What do others think?

David



David Jencks wrote:
> Why not use dependency injection for logging also?  Define a simple  
> logging interface in pluto, and include it as a constructor argument in 
> every service that logs stuff.  Writing an adapter to your favorite 
> logging implementation can then be done by the user for whatever system 
> they choose.
> 
> thanks
> david jencks
> 
> On Dec 22, 2004, at 6:54 PM, ricky_frost@peoplesoft.com wrote:
> 
>>
>> Ken,
>>
>> I agree with your point in general, but I'm glad you used the logger
>> service as your example. My $.02... Can the LogService be gutted entirely
>> and replaced with direct java.util.logging.Logger calls? I think this is
>> dead code now that JDK14 is baseline for most folks...
>>
>> I realize I may get lots of flames from dyed-in-the-wool, commons-logging
>> folks, but why should we need a "service" for something in the JDK?
>>
>> p.s. I tried to use the Jdk14Logger in commons for Pluto. But because of
>> the stackElements[2] method of getting the caller names, the log file
>> entries were all "LoggerImpl log" as the logging method... So I ended up
>> writing my own commons-logger LogServiceImpl just for Pluto...
>>
>> kramirez@TheJavaThinkTank.com said:
>> ...
>> Another advantage is that much of the Service Lookup that would need 
>> to be
>> implemented within Pluto (e.g. logger lookup service) could be totally
>> removed, making the Pluto code much easier to understand.
>> ...
>>
>>
> 
> 


Re: Pluto 1.1 Logging (was Re: Dependency injection in Pluto 1.1)

Posted by Ralph Goers <Ra...@dslextreme.com>.
Ken Weiner wrote:

> David,
>
> We had a long discussion on the uPortal developers list about this 
> same choice.  We ended up going with (2) because typically with 
> logging, you call a factory, passing it your class name so that the 
> logger it returns is specific for your class.  With DI, we didn't see 
> any easy way to do this because the IoC container doesn't know what 
> class to which it is injecting a logger.  I would be fine with 
> sticking with (2), straight use of commons-logging to retain 
> class-level logging granularity.
>
> -Ken

IMO, the only way to use IoC with logging is to use it to inject the 
LogFactory implementation, not for the loggers. As you stated, it would 
be terribly difficult for that.  Unfortunately, it doesn't look like 
commons-logging provides a good way to do that - you simply have to play 
by its rules and configure the Log implementation you want to use.   
That doesn't seem like to big a deal to me though.

Ralph


Re: Pluto 1.1 Logging (was Re: Dependency injection in Pluto 1.1)

Posted by Ken Weiner <kw...@unicon.net>.
David,

We had a long discussion on the uPortal developers list about this same 
choice.  We ended up going with (2) because typically with logging, you 
call a factory, passing it your class name so that the logger it returns 
is specific for your class.  With DI, we didn't see any easy way to do 
this because the IoC container doesn't know what class to which it is 
injecting a logger.  I would be fine with sticking with (2), straight 
use of commons-logging to retain class-level logging granularity.

-Ken

David H. DeWolf wrote:
> I personally prefer one of two approaches:
> 
> 1) Dependency Injection against a simple logging interface.
> 
> 2) Straight use of commons-logging.
> 
> The latter (commons-logging) is my preference simply because I find that 
> there are very few cases where you don't want SOME sort of logging. 
> Passing a logging implementation around to almost everything seems to 
> get out of control, and the user of commons-logging allows for a thin 
> adapter to whatever implementation is configured.
> 
> What do others think?
> 
> David
> 
> 

====
This message and any attachments are confidential. Unauthorized use
or disclosure of this message is strictly prohibited, and this message
must be destroyed immediately if received by an unauthorized recipient.
====

RE: Pluto 1.1 Logging (was Re: Dependency injection in Pluto 1.1)

Posted by Carsten Ziegeler <cz...@apache.org>.
Ralph Goers wrote:
> 
> David H. DeWolf wrote:
> 
> > I personally prefer one of two approaches:
> >
> > 1) Dependency Injection against a simple logging interface.
> >
> > 2) Straight use of commons-logging.
> >
> > The latter (commons-logging) is my preference simply because I find 
> > that there are very few cases where you don't want SOME sort of 
> > logging. Passing a logging implementation around to almost 
> everything 
> > seems to get out of control, and the user of commons-logging allows 
> > for a thin adapter to whatever implementation is configured.
> >
> > What do others think?
> >
> > David
> >
> Cocoon has had discussions on and off about switching from 
> logkit to log4j but has pretty much decided not to (at least 
> for now). The use of commons-logging in some projects has 
> caused all sorts of problems in JBoss.  We found today that 
> it works OK if you don't include the jar in your webapp.  Of 
> course, to have a common deployment across containers we have 
> to manually put commons-logging into other container's common 
> directories.
> 
> The following posts are fyi.
> 
> http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108671712905440&w=2
> http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108568210512989&w=2
> 
Logging is one of the most discussed topics :(
Today, I think directly using commons-logging or log4j is the easiest way
to go. Users are familiar with configuring these logging systems and
I see no need for providing an additional wrapper.

(Just because Ralph mentions it here, I hope we can get away with using
logkit in Cocoon someday and use directly either log4j or commons-logging).

So, imho we should go for 2) or use log4j but no own interfaces.

Carsten
 


Re: Pluto 1.1 Logging (was Re: Dependency injection in Pluto 1.1)

Posted by Ralph Goers <Ra...@dslextreme.com>.
David H. DeWolf wrote:

> I personally prefer one of two approaches:
>
> 1) Dependency Injection against a simple logging interface.
>
> 2) Straight use of commons-logging.
>
> The latter (commons-logging) is my preference simply because I find 
> that there are very few cases where you don't want SOME sort of 
> logging. Passing a logging implementation around to almost everything 
> seems to get out of control, and the user of commons-logging allows 
> for a thin adapter to whatever implementation is configured.
>
> What do others think?
>
> David
>
Cocoon has had discussions on and off about switching from logkit to 
log4j but has pretty much decided not to (at least for now). The use of 
commons-logging in some projects has caused all sorts of problems in 
JBoss.  We found today that it works OK if you don't include the jar in 
your webapp.  Of course, to have a common deployment across containers 
we have to manually put commons-logging into other container's common 
directories.

The following posts are fyi.

http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108671712905440&w=2
http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=108568210512989&w=2


Re: Pluto 1.1 Logging (was Re: Dependency injection in Pluto 1.1)

Posted by Ken Ramirez <kr...@thejavathinktank.org>.
I would vote for the 1st (DI using a simple interface), provided that 
you continue to include an default implementation for it, which can be 
replaced by the user community if need be.

Ken


David H. DeWolf wrote:

> I personally prefer one of two approaches:
>
> 1) Dependency Injection against a simple logging interface.
>
> 2) Straight use of commons-logging.
>
> The latter (commons-logging) is my preference simply because I find 
> that there are very few cases where you don't want SOME sort of 
> logging. Passing a logging implementation around to almost everything 
> seems to get out of control, and the user of commons-logging allows 
> for a thin adapter to whatever implementation is configured.
>
> What do others think?
>
> David
>
>
>
> David Jencks wrote:
>
>> Why not use dependency injection for logging also?  Define a simple  
>> logging interface in pluto, and include it as a constructor argument 
>> in every service that logs stuff.  Writing an adapter to your 
>> favorite logging implementation can then be done by the user for 
>> whatever system they choose.
>>
>> thanks
>> david jencks
>>
>> On Dec 22, 2004, at 6:54 PM, ricky_frost@peoplesoft.com wrote:
>>
>>>
>>> Ken,
>>>
>>> I agree with your point in general, but I'm glad you used the logger
>>> service as your example. My $.02... Can the LogService be gutted 
>>> entirely
>>> and replaced with direct java.util.logging.Logger calls? I think 
>>> this is
>>> dead code now that JDK14 is baseline for most folks...
>>>
>>> I realize I may get lots of flames from dyed-in-the-wool, 
>>> commons-logging
>>> folks, but why should we need a "service" for something in the JDK?
>>>
>>> p.s. I tried to use the Jdk14Logger in commons for Pluto. But 
>>> because of
>>> the stackElements[2] method of getting the caller names, the log file
>>> entries were all "LoggerImpl log" as the logging method... So I 
>>> ended up
>>> writing my own commons-logger LogServiceImpl just for Pluto...
>>>
>>> kramirez@TheJavaThinkTank.com said:
>>> ...
>>> Another advantage is that much of the Service Lookup that would need 
>>> to be
>>> implemented within Pluto (e.g. logger lookup service) could be totally
>>> removed, making the Pluto code much easier to understand.
>>> ...
>>>
>>>
>>
>>
>