Closed mumby0168 closed 10 months ago
Hi! There were two issues throwing you off, here.
First, in .NET 8 the default port for ASP.NET Core is 8080, not 80, so your service isn't actually listening on the exposed port.
Second, your call to UseSerilog()
overrides the initial logger configuration, and doesn't add any sinks - so Serilog is configured and working, but the messages aren't going anywhere.
You'll need to
5555:8080
CreateLogger()
to CreateBootstrapLogger()
Even better than 2 would be to ditch the JSON configuration altogether, and just configure the sinks you need in the initial CreateLogger()
call. In that case you don't need CreateBootstrapLogger()
, and don't need to pass a callback to UseSerilog()
. Simpler and pretty much bulletproof :-)
HTH!
Hi! There were two issues throwing you off, here.
First, in .NET 8 the default port for ASP.NET Core is 8080, not 80, so your service isn't actually listening on the exposed port.
Second, your call to
UseSerilog()
overrides the initial logger configuration, and doesn't add any sinks - so Serilog is configured and working, but the messages aren't going anywhere.You'll need to
- Change the compose file to map
5555:8080
- Add some sinks to the JSON configuration file, and change
CreateLogger()
toCreateBootstrapLogger()
Brilliant thank you very much @nblumhardt completely through me off that port change, it was a trial and error commented sections of my bootstrapping code out until it started to run some log information, so I've accidentally blamed serilog here.
Thanks for your help, all I needed was the port number change!
Description My container just hangs, see the below log out from a simple docker run:
Reproduction
I have put together a small repo here:
https://github.com/mumby0168/serilog-net8-repro
Just run
docker-compose up
in the root of the solution and notice you cannot hit the route endpoint on the application.It's a single file:
Expected behavior The app can be setup with logging and serve requests.
Relevant package, tooling and runtime versions
Additional context This only occurs inside a container, seems to run fine locally outside of the container.