Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LoggingLevelSwitch support #454

Closed
raV720 opened this issue Jan 3, 2023 · 6 comments
Closed

LoggingLevelSwitch support #454

raV720 opened this issue Jan 3, 2023 · 6 comments
Assignees

Comments

@raV720
Copy link

raV720 commented Jan 3, 2023

Does this sink support runtime changes of LogEventLevel? If not then it would be really helpful to implement such option.

@ckadluba
Copy link
Member

ckadluba commented Jan 4, 2023

Hi @raV720!

Thank you for writing us. The log level setting is not managed by this sink but can be controlled by Microsoft.Extension.Logging or by Serilog.Extension.Logging respectively. It should be able to update the log level property depending on the source of the setting (appsettings).

Further reading:
https://devblogs.microsoft.com/dotnet/asp-net-core-logging/
https://learn.microsoft.com/en-us/dotnet/core/extensions/logging?tabs=command-line#change-log-levels-in-a-running-app

@raV720
Copy link
Author

raV720 commented Jan 5, 2023

So according to https://learn.microsoft.com/en-us/dotnet/core/extensions/logging?tabs=command-line#change-log-levels-in-a-running-app it is not possible to change log level at runtime unless modifying appsetting.json?

Isn't it just matter of adding levelSwitch parameter in line:

@ckadluba
Copy link
Member

ckadluba commented Jan 5, 2023

The code you are referring to is only called once during initialization of the logger. It cannot be called again later during runtime of your app.

@raV720
Copy link
Author

raV720 commented Jan 5, 2023

Yes, but if I understand correctly: passed levelSwitch can be used later during runtime to change log level.

@ckadluba
Copy link
Member

ckadluba commented Jan 5, 2023

Ah, got ya! I will look into that.

@ckadluba
Copy link
Member

ckadluba commented Jan 8, 2023

We just released the preview version 6.2.0-dev-00041 to nuget.org which features a way to pass a LevelSwitch via the sink options object.

Please try it out and let us know if you find any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants