I guess I should have mentioned, though it's probably obvious, that I'm only interested in a configuration based solution. I'm not looking for a code solution. Thanks, Nick From: nic...@msn.com To: log4j-user@logging.apache.org Subject: RE: redefining existing levels? Date: Tue, 25 Aug 2015 16:05:47 -0400
Thanks for the reply. I've seen that documentation and it appears to be geared toward defining (NEW) custom levels. It doesn't mention anything about redefining existing log4j2 levels. I also tried it and so far in my testing it doesn't seem to work. Below is a snippet of my config. By the way, you'll see that I am currently trying the <CustomLevel> and <level>. At first I had just tried <CustomLevel> but it didn't appear to work so I thought I would put the same elements I have in my .NET config which work. Unfortunately it still doesn't work. . . . <level> <name value="OFF"/> <value value="500"/> </level> <CustomLevels> <CustomLevel name="OFF" intLevel="500"/> </CustomLevels> . . . <Loggers> <Logger name="HelloWorld" level="OFF"> <AppenderRef ref="debug"/> </Logger> <Root> </Root> </Loggers> I then set my logger level to "OFF" and didn't see any debug events show up. If I set the level to "DEBUG" they show up in the log. The docs say that DEBUG is set to 500, so me setting OFF to 500 and then setting the level on my logger to OFF should have allowed the debug events to flow to the log file, correct? Thanks, Nick > Date: Tue, 25 Aug 2015 12:50:32 -0700 > Subject: Re: redefining existing levels? > From: garydgreg...@gmail.com > To: log4j-user@logging.apache.org > > Nicholas, > > Yes, please see > https://logging.apache.org/log4j/2.x/manual/customloglevels.html > > If the documentation can be improved, please let us know how. > > Gary > > On Tue, Aug 25, 2015 at 12:42 PM, Nicholas Duane <nic...@msn.com> wrote: > > > Can existing log4j2 levels be redefined? I'm able to do this in log4net. > > I have yet to see any documentation telling me that I can do it, however, > > there was none telling me I could do it for .NET either. I just happen to > > stumble upon a post which eluded to it. Here is what I've done in a > > log4net config file: > > > > <configuration> > > . > > . > > . > > <log4net> > > <level> > > <name value="Off"/> > > <value value="40000"/> > > <level> > > <level> > > <name value="Business"/> > > <value value="130000"/> > > <level> > > . > > . > > . > > </log4net> > > . > > . > > . > > </configuration> > > > > As you can see I created my own 'Business' level. I also redefined Off to > > 40000 which happens to be the INFO level. This makes it such that if they > > set the level to Off they will still receive INFO and higher level events. > > > > Can the same thing be done in log4j2? > > > > Thanks, > > Nick > > > > > > > -- > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org > Java Persistence with Hibernate, Second Edition > <http://www.manning.com/bauer3/> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> > Spring Batch in Action <http://www.manning.com/templier/> > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory