Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

Interpolation string gets logged instead of full string of query and parameters as shown on console. #14

Open
carlos0202 opened this issue Dec 7, 2020 · 4 comments

Comments

@carlos0202
Copy link

I configured Dapper.Logging library to log SQL Server Dapper queries but when checking logs on Kibanna the message is always shown as this:
Dapper query: {query} Parameters: {params}, elapsed: {elapsed} ms, context: {@context}, connection: {@connection}

Startup config:
image

Console logs:
image

Kibana logs:
image

Expected result:
The Kibana logged message should be the same as the console log.

@carlos0202
Copy link
Author

Is this project abandoned/disbanded?
Thanks in advance for any help on this.

@hryz
Copy link
Owner

hryz commented Jan 31, 2021

Sorry for a really late reply. For some reason, I don't get notifications when somebody opens an issue.
Kibana uses 2 separate fields:

  • message = message template,
  • rendered message = message with all placeholder values baked in.
    This way you can filter out all the messages by their template.
    Are you sure that there's no rendered message field in the Kibana logs?

@carlos0202
Copy link
Author

Sorry for a really late reply. For some reason, I don't get notifications when somebody opens an issue.
Kibana uses 2 separate fields:

  • message = message template,
  • rendered message = message with all placeholder values baked in.
    This way you can filter out all the messages by their template.
    Are you sure that there's no rendered message field in the Kibana logs?

Sorry for my late reply as well. Right now, only the message (message template) is being sent to Kibana. How can I Send both parameters to Kibana using NLog? My configuration is as follows:

image

And:

image

But the result is the following:

image

The JSON object sent is missing the rendered message property.

@hryz
Copy link
Owner

hryz commented Apr 17, 2021

Hello @carlos0202 ,
I'm not an NLog expert, but it seems like structured logging using requires some additional configuration: https://github.com/NLog/NLog/wiki/How-to-use-structured-logging#using-structured-logging
Since the console output is fine, the issue is probably with a JSON/ELK sink configuration.
BTW, Serilog has structured logging out of the box and integrates with different sinks, including ELK in a few lines of code. I forgot when I saw other logging frameworks in modern projects the last time.

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

No branches or pull requests

2 participants