Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Using Serilog LoggingLevelSwitch

$
0
0

I'm still new to .NET Core and struggling a little bit with logging. I'm using Serilog for to perform my logging operations. I can get things to log and all that, but what I'd like to do is to be able to dynamically adjust the level of logging. So I'm trying to figure out how I am supposed to use their LoggingLevelSwitch in multiple spots.

https://nblumhardt.com/2014/10/dynamically-changing-the-serilog-level/

I can initialize and use it within "ConfigureServices" in Startup.cs. But then, later on, in one of my Controllers is where I'd like to be able to change it (like from "Warning" to "Information" or something).

How do I create a single instance of LoggingLevelSwitch, and use it throughout my web application? It seems like this would be something for dependency injection, but my brain is coming up blank. Can someone help point me in the right direction?

Thanks!


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>