Custom target with async attribute get incorrect timestamp and order of logs
See original GitHub issueNLog version: 4.6.5
Platform: WebApi 2.1 .net47
Current NLog config
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets async="true">
<target name="graylogt" xsi:type="GraylogHttp" facility="WebApi" graylogServer="http://graylog" graylogPort="12201">
<parameter name="current_user" layout="${aspnet-user-identity}" />
<parameter name="exception_type" layout="${exception:Type}" />
<parameter name="request" layout="${aspnet-request-method} ${aspnet-request-url}" />
<parameter name="site" layout="${iis-site-name} ${aspnet-appbasepath}" />
<parameter name="request_body" layout="${onexception:${aspnet-request-posted-body}:when=level>=LogLevel.Error}" />
</target>
</targets>
<rules>
<logger name="*" minlevel="debug" writeTo="graylogt" />
</rules>
</nlog>
Hi, I use a https://github.com/dustinchilson/NLog.Targets.GraylogHttp for graylog. In order to don’t block the thread for logging I use an async attribute. But logs have incorrect timestamps and order(compare to sync mode). I can’t use “sync” logs, because every log operation takes 0.2 sec.
- What is the current result?
Incorrect order and timestamp of logs
- What is the expected result?
Correct order and timestamps
Issue Analytics
- State:
- Created 4 years ago
- Comments:41 (22 by maintainers)
Top Results From Across the Web
NLog Async target timestamps
I know that according to What's the meaning of the time stamp in nlog when async is on? the timestamp is generated when...
Read more >Logging Cookbook — Python 3.11.4 documentation
This page contains a number of recipes related to logging, which have been found useful in ... Let's also assume that the file...
Read more >Log4j 2 Appenders - Apache Logging Services
The AsyncAppender accepts references to other Appenders and causes ... Date , then the log timestamp will be converted to that configured date...
Read more >Application Insights API for custom events and metrics
Use the Application Insights core telemetry API to send custom events and metrics and your own versions of standard telemetry.
Read more >Logging configuration
Configure the JSON logging extension using supported properties to customize its behavior. Determine whether to enable the JSON console formatting extension, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Created PR https://github.com/farzadpanahi/NLog.GelfLayout/pull/14 for you. Introduces a new setting
FixDuplicateTimestamp
(Default =False
)Can handle bursts of 9 unique timestamps within the same millisecond:
So my final nlog-config is
and here is my graylog input