Having an issue with missing log lines. We are creating individual logs per job passing by in a windows service. The log targets, log wrappers, logging rules and configurations are created dynamically using code.
If we run one or two jobs through the application, everything is logged fine.
If we run 4 simultaneous jobs, log lines in the middle of the log are missing. Missing chuncks of log. It is not that the log is prematurely ending. It comes back and logs again at the end. If we run it over again, there might be different log lines missing.
There aren't that many log lines per log per job. About 500 log lines.
Tried to increase the queue
Also having the log to grow.
Using NLog 4.5.9
The code:
could you please check the internal log?
Forgott to mention that i have a few errors in the internal log. However. same error even the times it logs ok as when it fails to log. I therefore bumped up the internal log level to TRACE. Unfortunately that slowed down the entire process, so it logged everything theat time. I will attach the internal log to the issue.
any idea what the cause is of the warning
error when formatting a message. Exception: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
it's there 84 times
This line will close the old configuration, and then initialize the new configuration. During this period any loggers actively being used might not reach a working NLog-Target (as they are closing and reopening):
LogManager.Configuration = config
I suggest that you just modify the configuration directly, instead of re-assigning the configuration. This is completely threadsafe and can be done without holding any locks:
LogManager.Configuration.AddRule("*." + jobId, GetLogLevel(LogLevel), targetWrapper):
LogManager.ReconfigExistingLoggers();
Thank you very much! Worked like a charm!