You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Fabrizio Squittieri <f....@comune.prato.it> on 2005/06/23 09:33:30 UTC

Creating our own logger

Hi there,
we have an old logger, an "homemade" one and now we want to switch our
logging to log4j.
We have to cope with the old one for the future as all the model
software written until now can't be rewritten to suite the old log.
Moreover we want a more powerful Logger class, as we must hold infos as
userAddress userName and so on.
 
In this scenario i thought to extend log4j and create my own Logger
class, in this way i can use all the log4j features and specialize
behaviour as we want.
I would like to have a common interface as i can see this new Logger by
this interface in my new model software where it arrives after been
created by a servlet (which will be responsible of setting extra infos)
whilst for the old software can be seen as the old logger.
 
So it would be
 
Logging interface (which?)     Old logger
                            ^              ^
                            |               |
                        My new Logger
 
But the point is that i can't see any interface implemented by log4j as
i hoped...
In fact i tuought it would have been a Logging interface implemented by
log4j and java.util.working...
That's not truth unfortunately.
 
What do you suggest?
Thanks
    
 
Fabrizio Squittieri - Programmatore
 
Sistema informativo - Comune di Prato
Via Cairoli 16 - Prato
0574615275 
 
f.squittieri@comune.prato.it
fabrizio@squittieri.it                              
 
 
 

Re: Creating our own logger

Posted by James Stauffer <st...@gmail.com>.
I had a similiar situation and I made our internal Logger class just
pass the event to log4j.  You can store userAddress and userName in
MDC.  Then weather the code uses the internal logger or log4j directly
it still ends up in the same place.  The only thing is that code using
the internal logger obviously didn't produce logs that were as good
(they all went to the same logger path, were all either error or info,
etc) because log4j was much better than our internal logger.

On 6/23/05, Fabrizio Squittieri <f....@comune.prato.it> wrote:
> Hi there,
> we have an old logger, an "homemade" one and now we want to switch our
> logging to log4j.
> We have to cope with the old one for the future as all the model
> software written until now can't be rewritten to suite the old log.
> Moreover we want a more powerful Logger class, as we must hold infos as
> userAddress userName and so on.
> 
> In this scenario i thought to extend log4j and create my own Logger
> class, in this way i can use all the log4j features and specialize
> behaviour as we want.
> I would like to have a common interface as i can see this new Logger by
> this interface in my new model software where it arrives after been
> created by a servlet (which will be responsible of setting extra infos)
> whilst for the old software can be seen as the old logger.
> 
> So it would be
> 
> Logging interface (which?)     Old logger
>                             ^              ^
>                             |               |
>                         My new Logger
> 
> But the point is that i can't see any interface implemented by log4j as
> i hoped...
> In fact i tuought it would have been a Logging interface implemented by
> log4j and java.util.working...
> That's not truth unfortunately.
> 
> What do you suggest?
> Thanks
> 
> 
> Fabrizio Squittieri - Programmatore
> 
> Sistema informativo - Comune di Prato
> Via Cairoli 16 - Prato
> 0574615275
> 
> f.squittieri@comune.prato.it
> fabrizio@squittieri.it
> 
> 
> 
> 
> 


-- 
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org