You can install the following packages through your IDE or go to the nuget link to grab the dotnet cli command.
Name | Link |
---|---|
Serilog.Extensions.Logging |
link |
Serilog.Sinks.Console |
link |
Serilog will be configured at the top of your async Main method, it looks like this
[!code-csharpConfiguring serilog]
For Serilog to log Discord events correctly, we have to map the Discord LogSeverity
to the Serilog LogEventLevel
. You can modify your log method to look like this.
[!code-csharpModifying your log method]
If you run your application now, you should see something similar to this
Now that you have set up Serilog, you can use it everywhere in your application by simply calling
[!code-csharpLog debug sample]
[!NOTE]
Depending on your configured log level, the log messages may or may not show up in your console. Refer to Serilog's github page for more information about log levels.