Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using NLog for Blazor Server Side

I am trying to use NLog on my project and following these steps I wonder how I could define the NLog lines in my Program.cs because there are no Main() and CreateHostBuilder() for Blazor server side.

Hope anyone can point me to right direction.

like image 448
MADJOE Avatar asked Jul 26 '26 05:07

MADJOE


1 Answers

Found it! It is

builder.Host.UseNLog();

Edited to add more samples:

builder.Logging.ClearProviders();
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Logging.AddNLog(new NLogProviderOptions {
        CaptureMessageTemplates = true,
        CaptureMessageProperties = true
    });
builder.Host.UseNLog();
like image 154
MADJOE Avatar answered Jul 29 '26 06:07

MADJOE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!