Here is a sample appSettings.json with configurations in place for Serilog
1 | { |
You can see a number of different sections
- NotesDatabaseSettings - ignore.
- Logging - this is standard stuff. It exists in all of my asp.net core configuration files.
- AllowedHosts - Ignore
- ConnectionStrings - Ignore - I have some code cleanup - to consolidate this block and NotesDatabaseSttings. But that is not serilog related.
- Serilog - this is code I added to hookup serilog.
The serilog block has a number of different sections
- MinimumLevel - is where you set the logging level. Development might be set to Information, production might be set to Error. I think this configures serilog to output to the console.
- WriteTo - This is used to configure Sync’s - places to send out logging data.. The first is “File” that is, the File sink. That is to configure logs into text files. I’m sending the logs to e:\t\NoteLog.txt. RollingInterval setups a daily file naming. And the formatter sends the output into a json format. Notice we wrap the file specification in brackets. This allows you to configure multiple logs.
- Enrich instructs serilog to add a MachineName, ProcessId, and ThreadId to the logging.