Closed williamdenton closed 2 years ago
there's some discussion on this twitter thread https://twitter.com/willdento/status/1445222796091486209
It seems this issue doesn't affect net6
Hello @williamdenton ,
My apologies, a lot of work at job last weeks. Cannot review your issue.
I have been reviewing the Twitter thread, and... I can conclude that you found what is happening in .NET 5.0?
Do you think that is there anything that can be changed from this extension to make it work?
Thank you very much.
hey @huorswords, i didn't figure out what was happening in net5, but did find that it works ok in net6. It's a mystery as to whether this is an issue with net5 or log4net.
GIven net6 is so close it probably not worth investigating this further.
The tweet you linked above is not a resolution to the issue rather an explanation of why it behaves the way it does for the person i am replying to there which is unrelated to this.
ill close this, as its resolved in net6
I have an app which I have migrated to net5 from net48. It uses log4net widely, so it made sense to keep using log4net.
I am using this package to configure the HostBuilder and it works - until the process is instructed to shutdown via
docker stop
which is aSIGTERM
signal.Expected behaviour
Logging continues to be written to the console until the logging system is disposed, which is when the host is disposed, which is after all components have exited.
Observed behaviour
ā
dotnet run
thenctrl+c
in a normal terminal works ādocker run --tty
thenctrl+c
works š“docker run
thendocker stop
(from another console) does not workSimple Reproduction:
Files:
net5shutdown.csproj
log4net.config
program.cs
Dockerfile
ā
dotnet run
thenctrl+c
in a normal terminal works here you can see the^C
and the shutdown messages from the hosted serviceā
docker run --tty
thenctrl+c
worksš“
docker run
thendocker stop
(from another console) does not workexpected log of
log=> stopped background service
andMicrosoft.Hosting.Lifetime [(null)] - Application is shutting down...
is not presentswapping the logging system for the simple console log
yields the correct log statements: