Setting the LOGGING__CONSOLE__FORMATTERNAME in aspnet6.0 image

Viewed 39

How do I set this environment variable when I run a .NET 6.0 docker file?

I have a docker image based off aspnet6.0 Docker file. By default the environment variable is set as Json. I want to set it to Simple without changing the code.

The console log formatter is here: https://docs.microsoft.com/en-us/dotnet/core/extensions/console-log-formatter

Can this be done?

I thought it would as simple as:

docker run --env LOGGING__CONSOLE__FORMATTERNAME=Simple <CONTAINER_NAME> 

This does set an environment variable with this name. However it does not overwrite the environment variable it results in a duplicate setting. I would expect making the above command to overwrite the setting for: LOGGING__CONSOLE__FORMATTERNAME.

Therefore my console is still formatted as JSON and not in Simple format as I expect.

1 Answers
Related