0

I'm quite new to C#, Json and Serilog for that. I just started a new gig and my first task is to create a logging function for the application using Serilog.

What is asked for: A logger that is always active and follows log levels from information and writes them in the file logs_information.log

Another logger which a user should be able to activate with a button that follows Debug and up and writes it in logs_debug.log.

Worth noting is that when the debug_logger is active it's still supposed to log to the logs_information. So it's not some sort of switch rather a filter that is added.

My initial thought was to create two different loggers but I think it's possible with just one.

This is my AppSettings.json:

enter image description here

What am I asking for? Some sort of guidance or useful tips, I tried using filters but the documentation seems to be lacking.

  • It sort of sounds like you want two different sinks (i.e. two entries in Serilog:WriteTo in your appsettings.json), and you want to be able to enable/disable one of them during runtime - is that correct? If so, you might want to [take a look at this](https://stackoverflow.com/a/57848453/6621862) – Luke Oct 06 '22 at 18:07
  • Please do not post code as images – Jason Oct 06 '22 at 21:06
  • @Luke, Basically yeah, but its important that the code is abstracted to the appsettings.json file. Which is where I hit a brick wall. The documentation overall is lacking. And I have been searching for some time. Can barely get serilog to write to two files with appsettings.json. But I do manage to get it working with code. So I want to beileve it's not impossible to get it to work with Json-formatting aswell. – Displayer4321 Oct 10 '22 at 19:32

0 Answers0