[logback-user] Localized log level names

Dario Campagna campagna at esteco.com
Wed May 30 16:13:23 CEST 2012

Hi all,

   Few days ago I started experimenting with the org.slf4j.cal10n
package for generating localized logs using logback.
That package easily allow one to obtain localized log messages.

Since SLF4J does not support localization of logger names and I need
them to be localized too, I made some modification to logback-classic
and used CAL10N to internationalize level names.

More precisely, I defined an enum type named Levels with the keys
I created resource bundles for some locales, e.g. levels_ja.properties
for the Japanese locale. I added to the Level class the constructor

 private Level(int levelInt, Enum<?> key) {
	this.levelInt = levelInt;
	IMessageConveyor mc = new MessageConveyor(Locale.getDefault());
	this.levelStr = mc.getMessage(key);

Finally, I defined the TRACE, DEBUG, INFO, WARN and ERROR using the
above constructor, e.g, for level TRACE

public static final Level TRACE = new Level(TRACE_INT, Levels.TRACE);

Thanks to this modification I am know able to obtain localized level
names in log files. I am wondering if this changes may be useful for
other logback users. If you have any suggestion/comment please do not
hesitate to respond to this email.


More information about the Logback-user mailing list