Pure Danger Tech


Should I localize log messages?

12 Jul 2007

Ok, I’ve got an open question for which I would like your opinion.

Should you localize log messages? To be clear, by localize I mean instead of a literal string value, should I instead look up a message defined by a ResourceBundle such that the message can be localized to the user’s locale if desired.

One argument says that the log is intended to be useful to the user in the case of abnormal behavior and is certainly accessible to the user and therefore just like all user-facing text (on a GUI, in an error message, etc), it should be localized.

An opposing argument could say that the log is primarily useful for support of the product and is thus only useful when created in a locale that the developers and support members actually can read. If I as a developer get a bug report from the field with a log localized in Japanese, I’m not going to be able to use that to track down the problem, thus negating the intended usefulness of the log in the first place.

What if the same message is both logged AND thrown back to the user? In this case, should you localize the message thrown to the user but log the unlocalized version? What if you localize an exception message which is later logged higher up the stack?

Is your answer different for different log levels (ERROR, WARN, INFO, DEBUG)? I think DEBUG messages should never be localized as they are never intended for user consumption, only for developer consumption. Do you agree? What about the other levels?