SeriLog won't log to railway?
samson
HOBBYOP

a year ago

Hey guys,

dumb question incoming...

I tried to setup serilog so i can log easier.

Doing this in Main()

using var logger = new LoggerConfiguration() .MinimumLevel.Debug() .Enrich.FromLogContext() .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] [{SourceContext}] {Message:lj}{NewLine}{Exception}") .CreateLogger();

Then this in ConfigureServices:

// Konfiguriere den DI-Container var serviceProvider = ConfigureServices();

services.AddLogging(loggingBuilder => { loggingBuilder.ClearProviders(); loggingBuilder.AddSerilog(); });

And this is a test log after ConfigureServices:

var _logger = serviceProvider.GetRequiredService>(); _logger.LogDebug($"ENVIRONMENT={Environment.GetEnvironmentVariable("ENVIRONMENT")}");

A normal Console.WriteLine() is shown in railway.

Any help is highly appreciated

Solved

11 Replies

samson
HOBBYOP

a year ago

24415e1c-9ff5-4133-b834-05af53c29590


a year ago

are those logs going to stdout / stderr?


samson
HOBBYOP

a year ago

should be. from what i read serilog logs to stdout / stderr


a year ago

is it unbuffered?


samson
HOBBYOP

a year ago

phew! how can i check that?


a year ago

i'm not familiar with how SeriLog works. your google is as good as mine here.


samson
HOBBYOP

a year ago

okay! i'm trying to get that info. 🙂


samson
HOBBYOP

a year ago

The Problem is the dsharpplus framework i use doesnt support DI Loggers like that.

I have to update it.

Thanks so far!


a year ago

no problem!

am I good to mark this as solved?


samson
HOBBYOP

a year ago

Yes i think so 🙂


a year ago

!s


Status changed to Solved brody about 1 year ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...