Runtime: Exception Handling / Error Logging in English

Created on 6 Aug 2020  ·  20Comments  ·  Source: dotnet/runtime

I have an application that is used in other countries. When receiving exception / error logs, they're invariably in other languages that I can't understand. I've looked into this, but had no luck. How do we force our C# .NET programs to log errors in English? If this currently isn't supported, please add it. I've seen requests for this around the Interwebz going back over a decade.

The user doesn't care about error logs. They are for developers; the vast majority of whom speak English.

area-Meta question

All 20 comments

This isn't a language request, but rather a runtime request. I'm going to transfer this over there, and hopefully they'll have an answer or can point you in the right direction.

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

Does .NET Core runtime itself do any localisation for the exception message? Most of the exception messages I'm seeing doesn't seem to be in my Windows UI language (Korean) and even if they are they seem to originate from Windows API or something.

Tagging subscribers to this area: @tarekgh, @safern, @krwq
See info in area-owners.md if you want to be subscribed.

@ChirChiara what version of.NET are you using?.NET Core's own resources aren't currently localized.

What strings are getting logged and which code do they come from?

Also you can force English resources if you set CultureInfo.CurrentUICulture to something like en-US Culture. Also, you can use the machine translation to translate the localized string.

For the record, I'm presently stuck with .NET Framework 3.5 on the app in question.

@333fred Thanks for moving it, I wasn't sure.
@svick I think that duplicate you referenced may also be in the wrong area if indeed it is a duplicate.

@tarekgh I definitely don't want machine translation because that quickly becomes a game of "operator" where details can be lost in translation. Also, CultureInfo.CurrentUICulture does not work in my case because this did not become read-write until 4.6.

Also, CultureInfo.CurrentUICulture does not work in my case because this did not become read-write until 4.6.

You can use Thread.CurrentThread.CurrentUICulture instead.
Also, you can set CultureInfo.DefaultThreadCurrentUICulture too to ensure other created threads later will get the english culture.

Side point, if you are talking about the full framework, then it is very unlikely such request will get added there. .NET core is our focus of future development and the full framework still supported but it is feature complete.

Yes on the first point, no on the second. CultureInfo.DefaultThreadCurrentUICulture is not available in my version, and Thread.CurrentThread.CurrentUICulture comes with a security warning, but will probably be my only option for now.

I agree with you that my code base will inevitably need to be updated, and that is planned for the future, but even in modern versions of .NET I don't see this ability to declare Exceptions be loggable in the language of your choice. I want to maintain that my users see the errors in whatever language they prefer, but the logs are belong to me (_intentional grammatical error_) and I need them in English. 😋

CultureInfo.DefaultThreadCurrentUICulture is not available in my version

CultureInfo.DefaultThreadCurrentUICulture is supported since version 4.5. are you running on 4.0? if so, definitely you need to upgrade.

3.5 SMH 🤦🏼‍♂️ Still trying to convince the PMs to let go of Windows XP support. 😫 I'm holding onto hope that we can finally do that on our next Major rev.

I hope you'll succeed with your mission :-)

do you mind if we close this issue as there is no action required here? feel free to send more questions if you need help with any issue you face.

I want to maintain that my users see the errors in whatever language they prefer, but the logs are belong to me (intentional grammatical error) and I need them in English.

... permanently set the UI culture as English, and then explicitly set the culture when doing all formatting/ToString()-ing? Although I'm not sure how that would affect some right-to-left text UI elements. Otherwise, are you saying that you're displaying raw exceptions to users?

I don't believe I got an answer to my question though; or did I miss it? Does anything in the .NET multiverse natively support logging Exceptions (for Developer use) in English?

Does anything in the .NET multiverse natively support logging Exceptions (for Developer use) in English?

There is nothing you can do without forcing the UI language on the app/running environment to English to guarantee getting English. Does the exception messages you are getting are the framework messages or app messages?

Framework of course. My app doesn't rely on any other third party APIs etc, so all app messages are written by me and already in English. It's the Framework that is generating Exceptions in the native culture of the client machine.

One other idea you may try is to uninstall the .NET Framework language packs from the machine. I don't have handy Windows XP machine but I believe you can do that from Control Panel, Add Or Remove programs options.

One other idea you may try is to uninstall the .NET Framework language packs from the machine.

🤦‍♂️
The use of implicit localization of the program, and even more of the localization of exceptions (which only developers see), was the most idiotic idea.

@Zymlex my suggestion was specific workaround for @Chiramisu case based on my question https://github.com/dotnet/runtime/issues/40427#issuecomment-670721303 and not intended to be for any situation. If you have any constructive feedback, please share it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jchannon picture jchannon  ·  3Comments

GitAntoinee picture GitAntoinee  ·  3Comments

noahfalk picture noahfalk  ·  3Comments

matty-hall picture matty-hall  ·  3Comments

iCodeWebApps picture iCodeWebApps  ·  3Comments