logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicholas Duane <nic...@msn.com>
Subject RE: status appender?
Date Mon, 14 Dec 2015 17:17:04 GMT
Thanks.  Yes, that's the one option I was thinking of.  Adding a console or file appender to
our logger.  However, the actual class in question is our DomainSocketAppender.  This is somewhat
related to a previous question I asked about capturing events from our appenders centrally.
 I guess in general, the advice is to log to the status logger in your log4j2 classes.  We
want to capture INFO - ERROR messages centrally so we're writing to our own logger within
our DomainSocketAppender.  It would be nice to have all other events, DEBUG and less specific
(or maybe just all events), go to the status logger and let the application team decide what
they want to do with status logger events.

I was just thinking that one other solution would be to log all events within our DomainSocketsAppender
to both its private logger and the status logger, thus somewhat removing the "routing" within
the code.  Our filter on the http appender already filters out anything less specific than


> Subject: Re: status appender?
> From: ralph.goers@dslextreme.com
> Date: Mon, 14 Dec 2015 09:32:51 -0700
> To: log4j-user@logging.apache.org
> First, what you are wanting to do is, in fact, pretty normal.  However, by default the
StatusLogger that Log4j uses for its components doesn’t use an Appender. Although the API
is the same the internals of the StatusLogger are actually quite different than the “normal”
Log4j implementation.  That said, the StatusLogger normally just writes to the console.  I
actually doubt that that is where you want your debug events to go.  Most people prefer them
to go to a rolling file.
> To accomplish what you want you just need to set up filtering in your configuration so
that the FATAL-INFO events go to one Appender and the DEBUG and TRACE events go to another
> Ralph
> > On Dec 14, 2015, at 8:34 AM, Nicholas Duane <nickdu@msn.com> wrote:
> > 
> > I'm curious if there is such a thing as a StatusAppender in log4j2 which, as you
would guess, is the appender the StatusLogger would use?
> > 
> > Here's what I'm trying to solve, I think.
> > 
> > I've been telling other developers I work with that a piece of code should only
write to a single logger.  The reason for this, in my mind, is that if a piece of code writes
to more than one logger then it essentially has routing logic in it and I would rather have
the routing in the configuration.  For example:
> > 
> > try
> >    {
> >    logger1.info(...);
> >    .
> >    .
> >    .
> >    logger2.debug(...);
> >    }
> > catch(Exception e)
> >    {
> >    logger1.error(...);
> >    }
> > 
> > The above code is sending debug events to a different logger than the rest of the
events it raises.  I would rather have the code send all events to a single logger and control
where those events are routed via the configuration.  Feel free to let me know whether this
is in line with logging principles.
> > 
> > So here's the problem.  We've got some code which writes events to its logger. 
We want to capture these events centrally so we're sending them to a central location via
an HTTP appender.  We want to do this only for FATAL - INFO events, so we're not expecting
a huge load.  DEBUG events however, we'd like to send to the same location as the status logger.
 We can, of course, just add a console appender for DEBUG events but that would have to be
controlled separately from the status logger and ideally it would be nice to just piggy back
on the status logger.  We could have this code write to its private logger and the status
logger for DEBUG events, but then we get into the routing issue I mentioned above.  So I'm
wondering, is there such a thing as a StatusAppender?
> > 
> > Thanks,
> > Nick
> > 		 	   		  
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message