Open
Description
Using serilog-enrichers-environment v2.1.3 with FROM mcr.microsoft.com/dotnet/core/runtime:3.1-buster-slim
on docker
MachineName appears to be null
, where the code below returns both inquiries with the correct value.
Console.WriteLine($"HOSTNAME: {Environment.GetEnvironmentVariable("HOSTNAME")}\nMACHINENAME: {Environment.MachineName}");
appsettings.json
"Serilog": {
"MinimumLevel": {
"Default": "Debug"
},
"Using": [
"Serilog.Sinks.Seq"
],
"WriteTo": [
{
"Name": "Seq",
"Args": {
"serverUrl": "http://localhost:5341"
}
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithThreadId",
"WithProcessId"
],
"Properties": {
"Configuration": "DEVELOPMENT",
"ApplicationName": "Test"
}
Program.cs
public class Program
{
public static async Task Main(string[] args)
{
Console.WriteLine($"HOSTNAME: {Environment.GetEnvironmentVariable("HOSTNAME")}\nMACHINENAME: {Environment.MachineName}");
await Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args)
.UseSerilog((hostingContext, loggerConfiguration) => loggerConfiguration
.ReadFrom.Configuration(hostingContext.Configuration)
)
.ConfigureServices((hostContext, services) =>
{
services.AddMyService(hostContext.Configuration);
})
.RunConsoleAsync();
}
}
Metadata
Metadata
Assignees
Labels
No labels