<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.0.2" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Should I localize log messages?</title>
	<link>http://tech.puredanger.com/2007/07/12/should-i-localize-log-messages/</link>
	<description>Alex Miller's technical blog</description>
	<pubDate>Thu, 20 Nov 2008 16:45:34 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>

	<item>
		<title>by: Kishore Senji</title>
		<link>http://tech.puredanger.com/2007/07/12/should-i-localize-log-messages/#comment-5607</link>
		<pubDate>Tue, 31 Jul 2007 06:34:40 +0000</pubDate>
		<guid>http://tech.puredanger.com/2007/07/12/should-i-localize-log-messages/#comment-5607</guid>
					<description>&amp;#62;&amp;#62; What if the same message is both logged AND thrown back to the user?

If the application is internationalized and localized in many languages, then using the same exception to log and show on the UI will not be that easy. Getting the locale, that the message needs to be localized in, to the business layer would also be cumbersome. It can be done however using Filters and ThreadLocals. A filter can pull up the locale from the user profile or the request headers and insert that Locale in to a ThreadLocal for later the business layer can use it, but for reasons others already mentioned, I think it will be better to just use English text in exceptions and log them and have some exception mapping facility, typically available in the MVCs now-a-days, to show the localized message in the UI.

Struts, and I think I have seen some other Apache projects, uses LocalStrings.properties and localizes messages based on the System default locale.</description>
		<content:encoded><![CDATA[<p>&gt;&gt; What if the same message is both logged AND thrown back to the user?</p>
<p>If the application is internationalized and localized in many languages, then using the same exception to log and show on the UI will not be that easy. Getting the locale, that the message needs to be localized in, to the business layer would also be cumbersome. It can be done however using Filters and ThreadLocals. A filter can pull up the locale from the user profile or the request headers and insert that Locale in to a ThreadLocal for later the business layer can use it, but for reasons others already mentioned, I think it will be better to just use English text in exceptions and log them and have some exception mapping facility, typically available in the MVCs now-a-days, to show the localized message in the UI.</p>
<p>Struts, and I think I have seen some other Apache projects, uses LocalStrings.properties and localizes messages based on the System default locale.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Alex</title>
		<link>http://tech.puredanger.com/2007/07/12/should-i-localize-log-messages/#comment-4983</link>
		<pubDate>Fri, 13 Jul 2007 21:19:48 +0000</pubDate>
		<guid>http://tech.puredanger.com/2007/07/12/should-i-localize-log-messages/#comment-4983</guid>
					<description>@Al: Ooops!  Guess you're right.</description>
		<content:encoded><![CDATA[<p>@Al: Ooops!  Guess you&#8217;re right.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Al Lang</title>
		<link>http://tech.puredanger.com/2007/07/12/should-i-localize-log-messages/#comment-4982</link>
		<pubDate>Fri, 13 Jul 2007 20:22:25 +0000</pubDate>
		<guid>http://tech.puredanger.com/2007/07/12/should-i-localize-log-messages/#comment-4982</guid>
					<description>@Laurie, @Alex - you have &quot;localisation&quot; and &quot;internationalisation&quot; backwards. &quot;Localisation&quot; means adapting to a specific locale, by providing translations/formats/whatever appropriate to that place. &quot;Internationalisation&quot; is the step that comes first, making it possible to localise by removing hardcoded strings/whatever.</description>
		<content:encoded><![CDATA[<p>@Laurie, @Alex - you have &#8220;localisation&#8221; and &#8220;internationalisation&#8221; backwards. &#8220;Localisation&#8221; means adapting to a specific locale, by providing translations/formats/whatever appropriate to that place. &#8220;Internationalisation&#8221; is the step that comes first, making it possible to localise by removing hardcoded strings/whatever.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Alex</title>
		<link>http://tech.puredanger.com/2007/07/12/should-i-localize-log-messages/#comment-4965</link>
		<pubDate>Fri, 13 Jul 2007 12:09:14 +0000</pubDate>
		<guid>http://tech.puredanger.com/2007/07/12/should-i-localize-log-messages/#comment-4965</guid>
					<description>@Keith: I've been down the error code path before and doing that for all log and error messages is madness.  That is only feasible and maintainable in the case of exceptions thrown through a very well-controlled API with a reasonably small error space.  

@Hamlet:  This implies that I can localize in the appender somehow.  If I'm using log4j for example, I would need to actually log a localization key, then have appenders that would know how to look up a localized message to go to one log and a hard-coded message to go to another.  I don't think such a thing exists, although it wouldn't be too hard to write one.  I actually went down a path similar to this years ago and found it to be a big mistake.  It made logging and exception handling way more complicated.

@Stefan: I think I've generally come to the same conclusion that localizing log messages is not worth the effort.  I can envision a system where some specialized kinds of logs (audit logs) may be useful to localize but in general it seems like more trouble than its worth.  

@Laurie: Good points.  I think I'd be willing to say at this point that the log's value is only for support and thus should not be localized.  I think it's also worth noting on your l10n/i18n comment that even localizing code has a big impact on your code base.  Localizing makes code harder to read (as you have message keys, not messages in it), harder to maintain (refactoring often requires being sensitive to the location of messages in various bundles), and localizing when you don't need to can make the process of i18n much more complicated for your translators as they need to know what messages do and do not need to be i18n'ed.  So, there is much value in NOT localizing stuff that doesn't need to be.

@Devil'sAdvocate: Good points all.  I'd say that even though your point about message content is generally true, it would still be a lot more difficult to understand what's happening in a log written in a different language, particularly if the variables being filled in are also in the other language.  

@Per:  On the last point, there is a certain class of exception whose purpose is to notify the user of a problem in user input and in that case, the exception message should be created for the purpose of display to a user.  But I agree that that is hopefully a small subset of the total number of exception messages in a product.  The rest are probably &quot;unexpected&quot; error conditions.  However, all exception messages have a way of &quot;bubbling up&quot; to the top of the app and getting seen by a user.  My general experience has been that the state of the practice in this area is far from the ideal, for the underestandable reason that it's a lot harder to manage than any sane person would expect.</description>
		<content:encoded><![CDATA[<p>@Keith: I&#8217;ve been down the error code path before and doing that for all log and error messages is madness.  That is only feasible and maintainable in the case of exceptions thrown through a very well-controlled API with a reasonably small error space.  </p>
<p>@Hamlet:  This implies that I can localize in the appender somehow.  If I&#8217;m using log4j for example, I would need to actually log a localization key, then have appenders that would know how to look up a localized message to go to one log and a hard-coded message to go to another.  I don&#8217;t think such a thing exists, although it wouldn&#8217;t be too hard to write one.  I actually went down a path similar to this years ago and found it to be a big mistake.  It made logging and exception handling way more complicated.</p>
<p>@Stefan: I think I&#8217;ve generally come to the same conclusion that localizing log messages is not worth the effort.  I can envision a system where some specialized kinds of logs (audit logs) may be useful to localize but in general it seems like more trouble than its worth.  </p>
<p>@Laurie: Good points.  I think I&#8217;d be willing to say at this point that the log&#8217;s value is only for support and thus should not be localized.  I think it&#8217;s also worth noting on your l10n/i18n comment that even localizing code has a big impact on your code base.  Localizing makes code harder to read (as you have message keys, not messages in it), harder to maintain (refactoring often requires being sensitive to the location of messages in various bundles), and localizing when you don&#8217;t need to can make the process of i18n much more complicated for your translators as they need to know what messages do and do not need to be i18n&#8217;ed.  So, there is much value in NOT localizing stuff that doesn&#8217;t need to be.</p>
<p>@Devil&#8217;sAdvocate: Good points all.  I&#8217;d say that even though your point about message content is generally true, it would still be a lot more difficult to understand what&#8217;s happening in a log written in a different language, particularly if the variables being filled in are also in the other language.  </p>
<p>@Per:  On the last point, there is a certain class of exception whose purpose is to notify the user of a problem in user input and in that case, the exception message should be created for the purpose of display to a user.  But I agree that that is hopefully a small subset of the total number of exception messages in a product.  The rest are probably &#8220;unexpected&#8221; error conditions.  However, all exception messages have a way of &#8220;bubbling up&#8221; to the top of the app and getting seen by a user.  My general experience has been that the state of the practice in this area is far from the ideal, for the underestandable reason that it&#8217;s a lot harder to manage than any sane person would expect.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Per Olesen</title>
		<link>http://tech.puredanger.com/2007/07/12/should-i-localize-log-messages/#comment-4959</link>
		<pubDate>Fri, 13 Jul 2007 06:20:06 +0000</pubDate>
		<guid>http://tech.puredanger.com/2007/07/12/should-i-localize-log-messages/#comment-4959</guid>
					<description>I for one hate localized log messages when I see them in other products. Living in Denmark and being a Dane, I sometimes see linux installations where they have been localized so not only the UI is danish, but also messages from tools like cd, ls, ln, tar, ... and it is absolutely *horrible*.

Another thing: It makes it harder to write tools that searches logs for stuff, when the messages are (can be) localized in different installations.

About exception messages being presented to the user: Isn't that a bad idea? I believe in catching exception in code and then -- if the user is to be notified -- showing a translated/localized message from some resource bundle.</description>
		<content:encoded><![CDATA[<p>I for one hate localized log messages when I see them in other products. Living in Denmark and being a Dane, I sometimes see linux installations where they have been localized so not only the UI is danish, but also messages from tools like cd, ls, ln, tar, &#8230; and it is absolutely *horrible*.</p>
<p>Another thing: It makes it harder to write tools that searches logs for stuff, when the messages are (can be) localized in different installations.</p>
<p>About exception messages being presented to the user: Isn&#8217;t that a bad idea? I believe in catching exception in code and then &#8212; if the user is to be notified &#8212; showing a translated/localized message from some resource bundle.
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
