Oops...I hit some strange keyboard combination and the email was sent prematurely...I'll finish the email inline below....
-----Original Message----- From: David Hosier [mailto:[EMAIL PROTECTED] Sent: Monday, May 08, 2006 7:35 AM To: 'Log4J Users List' Subject: RE: Logger vs. Appender 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: <category name="org.jboss.system.server.Server"> <priority value="INFO" /> <appender-ref ref="TRAP_LOG"/> </category> Then I can just use a common Category name for a Logger that needs to log my events (since you don't HAVE to use the Class name as the Category name). So if I want to log certain events with this Appender and others with the normal Appenders (File and Console) in one Class, I can just create two Logger instances in that Class, one with the Category set as the Class name and the other with some common name. I assume that I can use the log4j configuration to limit the Appender's use to only specific Category and Level configurations (i.e. I want the Appender to only be used by a specific Category). I'm assuming that the configuration example above only limits the Category and Level combination to the Appender and not the other way around. Does this sound like the correct track to pursue? Thanks. -----Original Message----- From: David Hosier [mailto:[EMAIL PROTECTED] 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:[EMAIL PROTECTED] 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]