Log messages not always saved to db - (Maybe flushing issue?) #635
Unanswered
johnhwright
asked this question in
Q&A
Replies: 1 comment
-
Hi @johnhwright Thank you for getting in touch. There ia a batched and a non batched (audit) version of the MSSQL sink. To confirm your suspicion, that the problem you see is caused by the batching, could you please test again after replacing the Cheers, |
Beta Was this translation helpful? Give feedback.
0 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.
Uh oh!
There was an error while loading. Please reload this page.
-
I keep going back and forth on whether this would be better posted in the hangfire or the serilog forums, but figure there are tons of people who use hangfire and not serilog, but I'm looking for people who happen to use both serilog and maybe hangfire.
In short, we use hangfire to run some nightly work and we log during these jobs using serilog - specifically the mssqlserver sink. Most days this works perfect, other days it only logs maybe the very first message (basically "Job Starting"), this is for the exact same job and expected outcome. that it just performed hours earlier.
At first we thought maybe some kind of exception was happening, but we added the basic file log sink and it writes the messages there every time. So it's nice that we have this file log to fall back on, but would really like the mssqlserver sink to work so we can query the results in the app.
I can only assume it has something to do with the batching / flushing. But we're using the static logger (
Log.Logger = loggerConfig.CreateLogger();
) and everything I've read so far seems to say that using the Host.UseSerilog() extension method is properly configuring any necessary CloseAndFlush(). And there are no actual application errors or anything that would cause it to not reach the default 5 second wait and flush anyway. The applications itself never shuts down during this period and continues to process more work.Our configuration:
Asp.net core app with .NET 9.
Hangfire 1.8
Serilog 4.2.0
Serilog.Sinks.MSSqlServer 8.2.2
Our program.cs:
Our MSSqlServer sink config:
Anyone have any ideas or places to start?
Beta Was this translation helpful? Give feedback.
All reactions