logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Hosier" <da...@longviewsoftware.com>
Subject RE: Logger vs. Appender
Date Mon, 08 May 2006 14:35:16 GMT
So I was thinking about this in my sleep....I think I could probably just
create a custom Appender.  Then in my configuration file, I can apply that
Appender to a specific level for a specific Category like the following
Jboss example:


-----Original Message-----
From: David Hosier [mailto:david@longviewsoftware.com] 
Sent: Sunday, May 07, 2006 11:34 PM
To: 'Log4J Users List'
Subject: RE: Logger vs. Appender

Thanks for the response.  I need to create a logging solution that handles a
very specific set of actions, while simply using the standard Logger and
Appenders for everything else.  I've just always passed in String logging
messages and used the File and Console Appenders.  But now I need to put
only some logs into a database (which implies one of the JDBC Appenders that
are available).  However, the events that need to be logged to the database
will have different information depending on the event type (different
number of discrete data points, etc).  So that led me to think that
extending Logger would be better.  

My initial thought was to create a Class hierarchy that represented the
events I need to log to the database, and pass instances of those classes
into my own Logger.  The Logger would put different types into different
tables using the info() method, and then I would just pass all other levels
to the Logger superclass (just for completeness, since I would probably
never use the other levels).  So the basic issue is that I want to pass any
number of different Object types into the Logger calls, and I don't know how
best to handle that since I've only ever used Strings and Throwables in
logging calls before.  And I want to be clear that I don't want to just use
some JDBC Appender that takes strings and inserts them into a database with
some other information like a timestamp or other info that you might see in
the FileAppender.  For example, one event that needs to be logged may need
to insert three values into a database, while another might need to insert
five.

Anyway...thanks again for the reply, looking forward to hearing other
people's thoughts.

-----Original Message-----
From: Curt Arnold [mailto:carnold@apache.org]
Sent: Sunday, May 07, 2006 10:57 PM
To: Log4J Users List
Subject: Re: Logger vs. Appender

An appender corresponds to the destination of a logging request, like a
file, email, database record, network packet, etc.  Creating a custom
appender to support new types of destinations is a common practice and well
supported.

A logger corresponds to a topic of a logging request, like requests  
related to database activity, security or a particular class.   
Creating custom logger implementations is not a common practice.  The
typical motivation to create a custom logger implementation is to support
additional levels.  In most cases, the desire for additional new levels is
due to a misunderstanding of the role of logger names (to represent topics
or intended audience).  If you feel that a custom Appender is not adequate,
please describe to the list your needs and we should be able to help suggest
possibly solutions other than extending Logger.


On May 7, 2006, at 7:49 PM, David Hosier wrote:

> Could anyone describe, or point me at resources that would describe, 
> the differences between creating your own Logger vs. creating your own 
> Appender for achieving custom logging behavior?  Thanks.
>
> -David
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org


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



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



---------------------------------------------------------------------
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