Hello all,
I finally have more time as a major deadline has passed at work. I was thinking about writing an improved JDBC appender. My intention is to create a new appender from scratch. As discussed previously, I figured I would have an abstract base class with an abstract getConnection() class and two concrete derivatives; one for getting the connection from a JNDI context and one for getting the connection from the DriverManager.
As suggested by others, it is preferable to use composition to offer choices. Offering choices by derivation (or inheritance) is OK as long as you have a single choice, for example the connection type. However, if you would also like the offer a choice on say LoggingEvent to DB mapping, then inheritance will result in combinatorial explosion.
I just wanted to check in to see if anybody is working on this already.
Not at the moment.
1) The original JDBCAppender class has a buffer where it stored the events until a limit is hit. I'm not sure I understand the rationale behind this. Doesn't this cause most loggings to be fast but once in a while one client pays the bill for the rest? It also seems to have been a source of bugs in the past. Does anyone have a compelling reason for including it in the new appenders?
In my opinion, no compelling reason whatsoever.
2) Is there a good place to look to get a feel for how the configuration works?
The options, a.k.a. properties, of appenders, layouts or filters are inferred dynamically using standard JavaBeans conventions. Any setter method taking a single primitive java type, an Integer, a Long, a String or a Boolean parameter implies an option name. For example, given that the FileAppender class contains setAppend(boolean), setBufferSize(int) and setFile(String) as member methods, then it follows that Append, BufferSize and File are all valid option names. Log4j can also deal with setter methods taking an org.apache.log4j.Level parameter. For example, since the AppenderSkeleton class[1] has setThreshold(Level) as a member method, Threshold is a valid option for all log4j appenders extending the AppenderSkeleton class.
In log4j version 1.3, you can also include sub-components in config files written in XML. Seeing a sub-element within an appender element, DOMConfigurator will automatically instantiate and configure the sub-element. I'll write complete example within the next few days. If I forget, please do not hesitate to remind me.
Thanks, Ray
--
Ceki
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]