10 months 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
11 Replies
10 months ago
are those logs going to stdout / stderr?
10 months ago
is it unbuffered?
10 months ago
i'm not familiar with how SeriLog works. your google is as good as mine here.
The Problem is the dsharpplus framework i use doesnt support DI Loggers like that.
I have to update it.
Thanks so far!
10 months ago
no problem!
am I good to mark this as solved?
10 months ago
!s
Status changed to Solved brody • 10 months ago