Having an ILogger shut down when my ASP.NET Core app shuts down #52490
Unanswered
DavidThielen
asked this question in
Q&A
Replies: 2 comments 8 replies
-
I think as an immediate workaround you can implement a hosted service that will release resources of your provider. |
Beta Was this translation helpful? Give feedback.
2 replies
-
It should be called on shutdown, how did you add the provider to the DI container? |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all;
This is in a Blazor server app. I have an ILoggerProvider that I created. It buffers log output and writes it (to an Azure BLOB) every 2 minutes. When the server shuts down, I need to have it flush the buffered output and write it to the BLOB.
Is there a way to do this? I implemented
Dispose()
but it appears to not be called on a shutdown. Do I need to register my ILoggerProvider in some special way?And if there is no way in the ILogger framework to do this, is there a way to have the App Server (I use Azure) call a method in my code on shutdown? If so, I can then directly call the logger to flush.
thanks - dave
Beta Was this translation helpful? Give feedback.
All reactions