At 11:13 06.03.2001 -0600, Johnson, Clay wrote:
>Folks, 
>
>I have a requirement to defer l10n processing to appenders, rather than at
>the publisher of the log event, in order that different appenders may
>localize the same event according to different locales.  Since the l10n
>methods in Category rely on preregistered ResourceBundles, that doesn't
>work. Furthermore, with only a cursory look at the internals, it appears
>log4j converts the message Object to a String to construct a LoggingEvent
>*prior* to distributing that to all appenders.  If that is true, I worry
>whether my requirement can be met without substantial
>modification/extension.

Starting with version 1.1, log4j allows layouts/appenders to access the raw message 
object. See getMessage() in org.apache.log4j.spi.LoggingEvent. So you can write an 
Appender that will convert a message string in a local specific manner.

Before going on, it is useful to consider the l7dlog methods in the Category class:

// Log a localized and parameterized message:
void l7dlog(Priority priority, String key, Object[] params, Throwable t) 

// Log a localized message: 
void l7dlog(Priority priority, String key, Throwable t) 

These methods consider the second parameter as a key in a ResourceBundle and not as a 
string message. The LoggingEvent class only considers message objects not message keys 
nor parameters to the localized conversion. 

It is clear that LoggingEvent must be extended, possibly by sub-classing, to include a 
key and parameters (of type Object array) to cater for the localized logging case. 

The other problem is to choose method signatures that allow both message logging and 
localized logging. Any suggestions? Ceki

 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to