3
votes

I've been researching about how to use Serilog to write to Azure log stream. I found a few answers here too; for example, one answer was suggesting to log to a file in a specific folder (home\LogFiles\http\...), but it doesn't seem to be working for me.

I tried using Trace and Debug sinks, but I couldn't see my messages in Azure log stream.

To make matters even more confusing for me, even using System.Diagnostics.Debug or System.Diagnostics.Trace doesn't work either.

So, maybe two questions:

  • How should I write to Azure log stream, in general?
  • Is it possible to use Serilog infrastructure while also writing to the log stream?

It goes without saying that I have enabled "Diagnostic Logs" in my Azure App Service.

Any help is truly appreciated,

Thank you

1
Have you enabled the filesystem diagnostic logs? :) Diagnostic logs in Storage are not streamed. - juunas
Yes, I have enabled the file system logging - Farzad

1 Answers

6
votes

The file sink has been reported to work correctly with the following configuration:

    .WriteTo.File(
         @"D:\home\LogFiles\Application\myapp.txt",
        fileSizeLimitBytes: 1_000_000,
        rollOnFileSizeLimit: true,
        shared: true,
        flushToDiskInterval: TimeSpan.FromSeconds(1))

There are a few subtleties to watch - shared: and flushToDiskInterval: especially.