C
C#7mo ago
Immortal

Is this the correct way to replace to replace a discord bot background service logger with Serilog?

https://paste.mod.gg/dblzdkrlozuv/0 I did see that there is an example of doing this on github however the example uses a console app instead of a worker service. And while this method seems to work from the messages that are in the console, it is doesn't allow me to use the Serilog methods so I have: _logger.LogInformation("Bot starting..."); Instead of using the Serilog methods like so: _logger.Information("Bot starting..."); Which makes me think this isn't the correct way to do this.
5 Replies
jcotton42
jcotton427mo ago
GitHub
GitHub - serilog/serilog-extensions-hosting: Serilog logging for Mi...
Serilog logging for Microsoft.Extensions.Hosting. Contribute to serilog/serilog-extensions-hosting development by creating an account on GitHub.
jcotton42
jcotton427mo ago
And use ILogger in your classes
Immortal
ImmortalOP7mo ago
Thanks, I made the changes you linked to and I'm pretty sure I need to add a builder.Logging.ClearProviders(); because after I changed my code to follow what was done in that example I'm getting duplicate logs.
No description
Immortal
ImmortalOP7mo ago
BlazeBin - morwnyhexhrc
A tool for sharing your source code with the world!
Immortal
ImmortalOP7mo ago
Here's my Bot class in case you need to see how I'm using it: (Sorry for ping) https://paste.mod.gg/oskmoomckcag/0
BlazeBin - oskmoomckcag
A tool for sharing your source code with the world!
Want results from more Discord servers?
Add your server