❔ Serilog file sink from multiple servers has interleaved messages
I have a web app deployed across 10 web servers. They are all configured as such (note, the
path
below is a shared network path. So they are all pointing to the same log file):
However I'm noticing the log file has interleaved messages:
2023-02-28 00:03:16.105 -06:00 [DBG] Execution plan of result filters (in the following order): ["Microsoft.AspNetCore.Mvc.Infrastructure.C2023-02-28 00:03:16.054 -06:00 [INF] Requ2023-02-28 00:03:16.130 -06:00 [DBG] Execution plan of result filters (in the following order):Notice the
[DBG]
and [INF]
log levels in the same message, and this here here specifically:
Infrastructure.C2023-02-28 00:03:16.054 -06:00 [INF] Requ2023-02-28 00:03:16.13How can I prevent this from happening? I thought
shared: true
was the support Serilog needed to handle this situation?7 Replies
So from what I can see, the SharedFileSink is only really applicable for multiple processes on the same server as it utilizes an os mutex. Are these servers on windows or Linux?
windows, app is running in IIS. the log file is at a network shared path that all apps are pointing to
Yeah, from everything I can see the shared functionality is implemented either by a lock or by a mutex, either of which is only going to work for multiple processes on the same box.
seems like a common use case, im pretty sure i use nlog on other apps and do the same thing without issue
i figured serilog would asynchronously try to log the message, such as building up a buffer, and then dump to the file as it is able to
I mean, it's kind of a common use case. At the point where you're running 10 servers logging to the same sink, I think the assumption is you're using a more mature log aggregation than a shared file
true
maybe time to switch to seq or something
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.