Farzad
Farzad

Reputation: 1930

Use Serilog with Azure Log Stream

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:

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

Any help is truly appreciated,

Thank you

Upvotes: 4

Views: 3232

Answers (1)

Nicholas Blumhardt
Nicholas Blumhardt

Reputation: 31797

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.

Upvotes: 7

Related Questions