question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Google.Cloud.Logging.NLog] Nlog logging structure

See original GitHub issue

Hi! Problem description I have the following structure at stack driver image using the following config: image and it’s pretty understandable but I have to meet some standards where properties are in a flat structure. Something like that is expected:

  "jsonPayload": {    
    "someProperty": "propertyValue",
    "message": "2020-11-24 11:50:32.192 | INFO | InfoTrace | traceId:  | Hawk Server-1.0.0: started ",
   ...
  },

where someProperty is near the message in structure. Isn’t it better to require a full JSON layout from API clients to define jsonPayload exactly as they want?

Describe the solution you’d like I have two solutions actually:

  1. Accept JsonLayout as user desire:
<layout xsi:type="JsonLayout" includeAllProperties="true">
                    <attribute name="message" layout="${defaultMessageFormat}" />
                    <attribute name="log_time" layout="${var:timeStampFormat}" />
                    <attribute name="team" layout="${var:team:default=dotnet}" />
                    <attribute name="service" layout="${var:serviceName:default=anonymous}" />
  </layout>

but it can be a breaking change, for that

  1. By default all properties will be placed at properties object but with some prefixes like .someProperty properties are going to be at the root object

Additional context It’s something I really need now, but maybe there is a possibility to do that somehow? I can implement that, but I think greenlight is needed before. Thanks in advance for your help and time.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jskeetcommented, Nov 25, 2020

Hmm… do you mean that even without any code changes, if you specify a JsonLayout that will be activated by NLog, possibly in the “rendering” part of the code? (I’m afraid I don’t use NLog myself normally, so this is all a bit new to me.)

If that is what you mean, option 3 is probably the cleanest in my view - it’s the most predictable, even if it feels a little clunky. In terms of a name, I think I’ll need to see what the code (and a test!) looks like first, as that will make me more aware of which NLog features it’s using. But yes, we can definitely discuss options about that.

In terms of documentation, I totally agree that we’ll want to document it, but you can probably leave that with me. Currently we have a bit of documentation in the README.md, but that should probably be moved into a docs/index.md file which I’m happy to do… and document this at the same time. At that point it would end up at https://googleapis.dev/dotnet/Google.Cloud.Logging.NLog/latest/index.html - or perhaps a separate “just configuration options” page linked from there and hosted in the same place.

0reactions
jskeetcommented, Dec 8, 2020

This has now been released in Google.Cloud.Logging.NLog version 3.2.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Google.Cloud.Logging.NLog
NLog is a .NET client library to integrate Google Stackdriver Logging with NLog. Note: This documentation is for version 4.0.0 of the library....
Read more >
Google.Cloud.Logging.V2
Cloud. Logging. V2 is a.NET client library for the Google Cloud Logging API. Note: This documentation is for version 4.1.
Read more >
Using Nlog to write structured logs to Google Stackdriver
I'm using the Google.Cloud.Logging.NLog target to write logs to Stackdriver. I'd like to use Nlog & Stackdriver structured logging ...
Read more >
Google.Cloud.Logging.NLog 4.0.0
NLog target for the Google Cloud Logging API.
Read more >
Config options for NLog's configuration
Database · Writes log messages to the database using an ADO.NET provider. package NLog.Database ; InfluxDB · Writes NLog messages to InfluxDB v2...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found