Skip to content

Unable to add metadata #42

Open
Open
@sameer-kumar

Description

@sameer-kumar

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions