Skip to content
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

Unable to add metadata #42

Open
sameer-kumar opened this issue Jun 5, 2020 · 0 comments
Open

Unable to add metadata #42

sameer-kumar opened this issue Jun 5, 2020 · 0 comments

Comments

@sameer-kumar
Copy link

sameer-kumar commented Jun 5, 2020

I'm using Serilog.Extensions.Logging.File nuget package Version=2.0.0 in my AspNet Core 3.1 app.
This is what I have in my Program.cs file:

public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
               .ConfigureLogging((hostingContext, builder) =>
                {
                    builder.AddFile(hostingContext.Configuration.GetSection("Serilog"));
                    builder.AddSerilog(dispose: true);
                })

This is what I have in my appsettings.json

"Serilog": {
    "Using": [ "Serilog.Sinks.RollingFile" ],
    "Enrich": [
      "FromLogContext"
    ],
    "PathFormat": "Logs/myapp-{Date}.txt",
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    },
    "Json": false,
    "FileSizeLimitBytes": 1000000,
    "RetainedFileCountLimit": 3,
    "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level}] {Message}{NewLine}Properties: {Properties}{NewLine}MachineName: {MachineName}{NewLine}Application: {Application}{NewLine}{Exception}-------------------------------------------------------------------{NewLine}",
    "Properties": {
      "Application": "XWRA",
      "MachineName": "%COMPUTERNAME%"
    }
  }

It generates the txt file but not metadata of Application and Machine name.
I'm using Windows machine.
Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant