logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Curt Arnold <carn...@apache.org>
Subject Re: log4j - Level creation in config file
Date Tue, 03 Apr 2007 20:32:06 GMT

On Apr 3, 2007, at 1:38 PM, Eric.Wolf@bcbsks.com wrote:

>
>
>
>
> Can you create new Level(s) in the configuration file (for example:
> log4j.level.Audit = "something here"?
>
> Or should I just extend the Level class?
>
> Thanks,
> Eric Wolf
>

log4j doesn't support on-the-fly level creation in configuration  
files.  There had been some thought of allowing a numeric level value  
to be used, but no code has ever been placed around that.

I would strongly encourage you to think through your use cases (and  
perhaps describe them here).  Many times when custom levels are  
considered, the goal is actually to characterize the intended  
audience or destination of the message, both of which are better  
accomplished using the logger name than the level.   Level is a  
continuum of significance with certain values being assigned symbolic  
names (trace, debug, info, warn, error, fatal).   Does "audit" fit in  
there somewhere?

Likely it closer to a "topic" or "subject" that is better served use  
of the logger name?  Many people get misled into thinking that logger  
names have to be class names since it is a common use pattern (where  
it basically means a topic regarding the implementation of the class  
of the same name), but it is not limited to that.  I'd suggest  
thinking about having two distinct logger instances in your class,  
one named after the class to capture implementation diagnostics  
intended for diagnosticians and a separate one for messages intended  
for auditors.

public class Foo {
      private static final Logger logger = Logger.getLogger(Foo.class);
      //   you can play with logger name patterns to address your  
concerns
      private static final Logger auditLogger = Logger.getLogger 
("audit.revenue");


This discussion has been gone over quite a few times, you might  
search the archives for the following terms "audience", "audit",  
"diagnostician", "custom level".


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


Mime
View raw message