logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Young <lyo...@dalmatian.com>
Subject Re: discreet log types
Date Fri, 15 Aug 2003 00:52:00 GMT

         Yes, I need to be able to specify which class may display which 
set of discreet types.  For example, I might have "com.*" allowed to 
display ERROR, but then override that for "com.xyz.MyClass" to display only 
TIMING,  "com.abc.def.*" to display METHOD_TRACE & TIMING, and 
"com.abc.dataaccess.*" to display DB_ACCESS.

         I've been looking at the filter solution based on your original 
suggestion (thanks!).  But if I'm not mistaken, Filters can only be applied 
to Appenders, not Loggers.  So I would have to define multiple appenders, 
one for each logger that I have, or rather one for each logger I explicitly 
define in the config file.  That would seem to be rather cumbersome.  And 
using Ceki's solution, each logger is based on the type, so the filter 
would still apply to all classes, since there is no class information in 
the LogEvent class.  I could solve that using MDC, but I am still missing 
the critical piece which ties a specific class/package to a list of allowed 
logging types.

         The trick it seems to me is that I need to define the permitted 
logging types per class/package in the config file, just the way logging 
levels are defined today, either in conjunction with or as a replacement 
for.  Ultimately, if I want to be able to enable/disable logging types by a 
specific class/package (just like levels are), then I need to build that 
association somewhere.  I can define it either in the log4j config file, or 
in a separate config file (obviously, the fewer config files, the 
better!).  And that association needs to be maintained in memory at runtime 
either with the current logger sitting in the default repository, or in a 
new logger class in a separate repository, or in a totally separate global 
collection associating loggers to their allowed types.

         I am sorry if I'm not explaining myself very well.  I have a 
pretty clear idea in my head, but perhaps I'm not communicating it very 
well.  Thanks for all your input!

         I am still interested to hear if anyone on the list thinks that 
the idea of logging by discreet types is of interest and would be a useful 
feature for others out there besides myself.  BTW, I'll be out tomorrow, so 
I won't be checking my email again until Monday.  Have a good weekend!

--- regards ---

At 07:52 AM 8/15/03 +1000, you wrote:
>On Fri, 2003-08-15 at 07:49, Larry Young wrote:
> > Ceki,
> >
> >          That's an interesting way of looking at logger types!  But how
> > would that allow me to enable/disable log messages for a particular
> > class?  One of the features I need is the ability to specify that a
> > particular class should display a particular type of log message (or
> > possibly more than one).  This would appear to only let me set the message
> > type system wide.  Did I miss something?
>No, you haven't missed anything, it would set the types system wide, and
>allow you to specify the level system wide, but if that was not granular
>enough, can't you specific a particular Filter for your appender?  (i.e
>all classes logging to the DB logger, but you filter for a particular
>I'm sure you could write yourself a Filter sub-class very quickly and
>attach it to an Appender via the configuration.   You could configure
>this Filter impl with some configuration as to what classes you want to
>see output.
>Hope that makes sense.
>Paul Smith
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org

Larry Young
The Dalmatian Group

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

View raw message