logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kevin D. Carbis" <kcar...@marcole.com>
Subject RE: Internationalization with log4j ?
Date Thu, 04 Mar 2004 15:48:28 GMT
Well, FWIW here's how I did it:

I've defined an XML structure for messages such that each message is defined
by an ID and 1 or more TEXT nodes.  Each Text node is described by a Locale
and Text.

I have a Singleton dictionary object that loads this file at startup.  I
define the Locale in which I wish to log during initialization.   This
dictionary serves the messages in that Locale as LogMessage java objects.
(This could easily be done dynamically by passing a Locale at log time, we
don't happen to need that )

These LogMessage objects are what I pass on my log() invocations. Example:
	Logger.warn( new LogMessage( "MSG001" )) ;

Then all that is left is to write a custom renderer, LogMessageRenderer that
will render these LogMessage objects.  The renderer retrieves the message
from the aforementioned dictionary, which come in the desired language, and
substitutes parameters if necessary.

The renderer is easily tied to the LogMessage object in the log4j
initialization.

Hope it helps,
Kevin


Greetings,

I intend to realize my logging in my project with the log4j package, but I
need the internationalization of looging messages, e.g. written in German
or English language in a file depend on an attribut setting.
But I don't know to do this for the best, in a simple way.
In SYSLOG their are codes for facility/severity, which can be transformed
into the right text.
But how to manage the message itself, which normally is written in const
string in source code.

Thoughts and ideas about possible solutions would be very appreciated.


Regards,
Juergen Bauer


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