Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syslog logging just randomly stops #311

Open
karlra opened this issue Mar 8, 2023 · 6 comments
Open

Syslog logging just randomly stops #311

karlra opened this issue Mar 8, 2023 · 6 comments
Assignees
Labels

Comments

@karlra
Copy link

karlra commented Mar 8, 2023

Ask the question
We have a high-traffic system that uses this library to log to syslog.

However, at random times it just....stops. Nothing more gets logged to syslog even though I know for a fact that the methods get called. Can you give any sort of guidance as to what the problem might be and/or how to debug it?

Additional context

  • NLog version: 4.5.4
  • NLog.Targets.Syslog version 6.0.3
@snakefoot
Copy link
Contributor

snakefoot commented Mar 8, 2023

Think you need to capture a minidump from the application, and open that minidump in Visual Studio.

Then look at the thread callstacks using Visual Studio (maybe using Visual Studio Parallel Stacks), and determine why it is getting stuck.

When having pin-pointed the thread(s) causing the "stop", then you can paste the thread callstacks here for further investigation.

Have you tried upgrading to latest version?

@karlra
Copy link
Author

karlra commented Mar 8, 2023

I'll try that the next time it happens, but it's not easy because our systems have a lot of traffic and a lot of active threads. When I say stop, I don't mean that the application itself hangs up, because it keeps processing requests and there is no growth in memory usage either which would indicate queuing. Can you give me some kind of starting point at what I should be looking for in the minidump?

I am using these settings:

target.Enforcement.Throttling.Limit = 10000;
target.Enforcement.ReplaceInvalidCharacters = true;
target.Enforcement.Throttling.Strategy = NLog.Targets.Syslog.Settings.ThrottlingStrategy.Discard;
target.MessageCreation.Facility = NLog.Targets.Syslog.Settings.Facility.Local1;
target.MessageCreation.Rfc = NLog.Targets.Syslog.Settings.RfcNumber.Rfc5424;
target.MessageCreation.Rfc5424.DisableBom = true;

The behaviour suggest that it starts discarding messages but what could be causing that? I don't think there is anything wrong with our syslog because other sources (other apps on the same machine) keep writing successfully.

I'll try upgrading to the most recent version in the mean time.

@karlra
Copy link
Author

karlra commented Mar 15, 2023

It happened again and I dumped the process. There are no stuck threads, but there is a lot of NLog objects and I don't know why. Also there are over 10.000 NLog objects in a dictionary the LOH.

image

image

@snakefoot
Copy link
Contributor

snakefoot commented Mar 15, 2023

If you have a queue of pending NLog LogEvents that are not yet written, then they will ofcourse stay in memory.

The NLog MruCache is used for caching known object-types and their object-property-names.

You are using old NLog v4.5.4, which doesn't include this MruCache-Initial-Capacity-fix: NLog/NLog#4021

I can only recommend that you upgrade to NLog v4.7.15 (Or even better NLog v5)

@RyanGaudion
Copy link

@snakefoot this has happened multiple times for us too. Most recently using Nlog 5.2.8 and NLog.Targets.Syslog 7.0.0.

Just like @karlra - logs just stop being sent via syslog, however are still written to other targets such as log files.

It seems to occur when a very large log tries to be written (normally if serializing a very large object into the log). As per #313 we've tried to truncate our logs - but that doesn't seem to work either.

@snakefoot
Copy link
Contributor

snakefoot commented Jul 8, 2024

@RyanGaudion I know about the NLog-core, but I don't know much about the SysLog-target or your environment. Without providing details about where threads are stuck in your application along with memory-usage-details, then it is hard to guess the cause of your problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants