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 Steve Pruitt <SP...@exstream.com> on 2005/08/02 22:33:53 UTC
Custom level question
All,
I am adding a custom level for my application. The level name is
SESSION and it has a severity level between INFO and WARN.
Documentation says each level must have a unique integer value. I'm not
sure how to define the value for my level. Looks like it could either
be INFO + 1 or WARN - 1. But, I am a little confused. If the existing
levels are in simple order, doesn't INFO + 1 = WARN and wouldn't it
violate the uniqueness rule. Or, is there some progression used to
separate the builtin level values to make room for custom levels. Or,
do I completely misunderstand how the builtin levels are implemented?
-S
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Custom level question
Posted by Curt Arnold <ca...@apache.org>.
On Aug 2, 2005, at 3:33 PM, Steve Pruitt wrote:
> All,
>
> I am adding a custom level for my application. The level name is
> SESSION and it has a severity level between INFO and WARN.
> Documentation says each level must have a unique integer value.
> I'm not
> sure how to define the value for my level. Looks like it could either
> be INFO + 1 or WARN - 1. But, I am a little confused. If the
> existing
> levels are in simple order, doesn't INFO + 1 = WARN and wouldn't it
> violate the uniqueness rule. Or, is there some progression used to
> separate the builtin level values to make room for custom levels. Or,
> do I completely misunderstand how the builtin levels are implemented?
>
Are you very sure that you want to do this as a Level? From the name
it seems like your "Level" is more likely a class of information (or
less likely the intended audience) instead of the significance of the
message. Would definitely be simpler to use distinct loggers or
distinct logger hierarchy for the "session" information instead of
trying to add a new level.
I think level is wrong way to go, but I'd still like to make it
possible to introduce new levels without having to add code. Almost
all the internal stuff is based on the integer value, the most
significant role for the Level class is to implement the conversion
between integer values and a labels. It would be nice have some
generic code so that if you wanted, you could have 9999 levels
between INFO and WARN, but by default they'd be rendered as INFO+1000
or the like.
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org