-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Repeating db records multiple times #3770
Comments
Hi! Thanks for opening your first issue here! Please make sure to follow the issue template - so we could help you better! |
Please send me template |
|
@vikassaini80 I can see from you Nlog.config that you are very happy about <parameter name="@message" layout="${var:message}" />
<parameter name="@stacktrace" layout="${var:stacktrace}" /> This goes especially bad, when using Instead you should use the standard means for capturing context: https://github.com/NLog/NLog/wiki/Context The most optimal (and most simple) is capturing using the var logEvent = LogEventInfo() { Level = LogLevel.Info, Message = "Hello" };
logEvent.Properties["stacktrace"] = "HelloWorld.cs: Line 42";
logger.Log(logEvent); The more advanced solution is using MappedDiagnosticsLogicalContext - ${mdlc}: using (NLog.MappedDiagnosticsLogicalContext.SetScoped("clientCorrelationID", Guid.NewGuid()))
{
logger.Info("myLogEvent");
} |
Thanks For your reply, we are using {var:} to assigned the value and same we are sending to the db query can you please little elaborate how we can insert record in db using LogEventInfo() that will be really helpful. |
I have attached my nlog.config and trace file with this issue What is the current result? Some time we saw a single record is multiple times in db only while the same record in file is only single time which is expected. |
Have you even tried to read the Wiki-page about using Context that I gave to you? Example code: var logEvent = LogEventInfo() { Level = LogLevel.Info, Message = "Hello" };
logEvent.Properties["stacktrace"] = "HelloWorld.cs: Line 42";
logger.Log(logEvent); Example config: <parameter name="@message" layout="${message}" />
<parameter name="@stacktrace" layout="${event-properties:stacktrace}" /> |
Closing this due to inactivity. Please let us know if this still an issue and please provide the requested info - |
Wrote an answer on stackoverflow with some details: https://stackoverflow.com/questions/59875091/nlog-repeating-db-records-multiple-times-randomly-while-load-is-high |
Hello All
I am facing a issue with log db while i am inserting records in db its inserting multiple times while in file the same record is in single time, while i am checking the trace file its showing the exact no that i am able to see in my db but reason i dint know, Can someone please look into that and do let me know what causing the issue.
I am attaching trace file and nlog.config file please review it and do let me know what causing the issue.
NLog.zip
The text was updated successfully, but these errors were encountered: