serilog-sinks-azureblobstorage icon indicating copy to clipboard operation
serilog-sinks-azureblobstorage copied to clipboard

File is empty when using with WebJob

Open aorlenko83 opened this issue 5 years ago • 1 comments

Are there any considerations when using the package with appservice WebJob? I'm using .net core 2.2. In Program.cs:

var host = new HostBuilder()

                .UseConsoleLifetime()
                ....
                .UseSerilog((hostingContext, loggerConfiguration) =>
                {
                    loggerConfiguration.ReadFrom.Configuration(hostingContext.Configuration);
                })
                .Build();

The appsettings.json:

"Serilog": {

    "MinimumLevel": "Debug",

    "WriteTo": [
      {
        "Name": "AzureBlobStorage",
        "Args": {
          "connectionString": "comes-from-ci",
          "storageContainerName": "myapp",
          "storageFileName": "{yyyy}/{MM}/{dd}/log.txt"
        }
      },
      {
        "Name": "ColoredConsole"
      }
    ]
  },

As a result, the yyyy/MM/dd/log.txt file is created in the Blob storage, however the file is always 0B size.

Another question is, should I turn on any options in the App Service Logs in the AppService configuration when using this library?

Thanks

aorlenko83 avatar Aug 27 '19 19:08 aorlenko83

I was surprised that the file was created at all, because I thought that the library would have trouble getting a valid connection string.

That being said, I originally wrote this library to support logging in a WebJob, so I know that it works. I did most of my configuration in Program.cs, and didn't use appsettings.json for anything other than holding the connection string.

chriswill avatar Aug 29 '20 22:08 chriswill

Closing

chriswill avatar Jul 17 '24 01:07 chriswill