Skip to content

No localization in Logging/LogValuesFormatter (src/Logging/Logging.Analyzers/src/LogValuesFormatter.cs) #40242

Description

@Popsikill

Describe the bug

When logging (via an implemented ILogger such as Console) the date/numeric formats are not localized.
It appears currently there is no automatic localization of parameters in the LogValuesFormatter class - it is set to use the Invariant Culture.
As the Invariant Culture leans heavily toward American formatting - for the rest of the world this doesn't really fit.
Ideally we should be able to DI to specify what culture should be use - with Invariant Culture being the backup.

To Reproduce

Steps to reproduce the behavior:

  1. Microsoft.Extensions.Logging.Abstractions, Version 3.1.6.0
  2. Create a basic .net core project
  3. Configure to use ConsoleLogger
  4. Inject and use ILogger with a simple DateTime
    image
  5. Message reads as Invariant Culture date format Action to begin at 07/29/2020 12:52:12

Expected behavior

Expected to be able to override culture by either;

  • Setting CultureInfo.CurrentCulture (or one of it's variants),
  • Setting Thread.CurrentThread.CurrentCulture (or one of it's variants),
  • A localization package similar to ASP.NET Core's UseRequestLocalization that would be configurable for the use-cases.

Screenshots

N/A

Additional context

.NET Core SDK (reflecting any global.json):
Version: 3.1.302
Commit: 41faccf259

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\3.1.302\

Host (useful for support):
Version: 3.1.6
Commit: 3acd9b0cd1

.NET Core SDKs installed:
3.1.202 [C:\Program Files\dotnet\sdk]
3.1.301 [C:\Program Files\dotnet\sdk]
3.1.302 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions