0
votes

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.

Please find the attachment here:

https://github.com/NLog/NLog/issues/3770

1
What are you missing in the response, that you have already received? You should not use global NLog Config Variables ${var} for context capture. - Rolf Kristensen

1 Answers

0
votes

To elaborate Rolf's comment.

Small part of your config:

<parameter name="@ResponseCode" layout="${var:ResponseCode}" />

${var} is a global and isn't threadsafe. It not meant to change every logevent. There a other ways to send context to your database in a threadsafe way. See all options described here.

For this case probable the event properties is a good choice. You could use it like this:

logger.WithProperty("ResponseCode", responseCode).Info("Got response!");

Or structured logging style:

logger.Info("Got response with code {ResponseCode}!", responseCode);

And replace in your config ${var:ResponseCode} with ${event-properties:ReponseCode}