-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added WithEnvironmentName enricher #42
Conversation
Added support for 'EnvironmentName' property based on `DOTNET_ENVIRONMENT` or `ASPNETCORE_ENVIRONMENT` environment variable.Basically adds 'Production', 'Staging', 'Development', ... to the event logs.
should it be adding the property in the case where neither environment variable is set? |
We should probably add the property with value 'Production, as this seems to be the default case in the AspNetCore documentation and HostBuilder.CreateHostingEnvironment method. |
Set EnvironmentName fallback value to Production.
This seems reasonable based one the current contents of this library 👍 I wonder though if, in the bigger picture, we're not adding a lot here now that can't be written more obviously as variations of: .Enrich.WithProperty("EnvironmentName", Environment.GetEnvironmentVariable("DOTNET_ENVIRONMENT") ?? "Production") I notice that in the ASP.NET Core docs, it mentions that |
Think that's what #24 was getting at? |
The reason why I would add this to this package, is because it then can also be configured by adding The difference I see with #24 is that this is more a framework environment variable and #24 is a good solution for custom environment variables. Concerning the order of |
👍 thanks for the reply. I think we should follow the precedence the framework uses, since it would be confusing for the log to report e.g. "Production" while the app, using the variables in reverse order, might be in "Development" https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-5.0#environments is the doc:
Otherwise LGTM! |
The 'ASPNETCORE_ENVIRONMENT' value overrides 'DOTNET_ENVIRONMENT'.
OK, I concur. I changed the precedence to |
👍 |
Added support for 'EnvironmentName' property based on
DOTNET_ENVIRONMENT
orASPNETCORE_ENVIRONMENT
environment variable. Basically adds 'Production', 'Staging', 'Development', ... to the event logs.