Google-cloud-dotnet: Log4Net StackdriverAppender: Use %property values in custom labels

Created on 27 Mar 2019  路  8Comments  路  Source: googleapis/google-cloud-dotnet

Is your feature request related to a problem? Please describe.
Attempting to use %property syntax on custom label values. It shows up in Stackdriver like this:

labels: {
  Key:  "%property{AccountID}"   
...
 }

I want the value inserted at runtime, similar to what I can do with the message:

<conversionPattern value="%property{AccountID} ...

Describe the solution you'd like
I'd like to label my logs with some context from the application.

<customLabel>
      <key value="AccountID" />
      <value value="%property{AccountID}" />
</customLabel>

Describe alternatives you've considered
Put the dynamic data into the log message directly.

Additional context

logging p2 feature request

All 8 comments

Assigning to Chris to consider this.

@chrisdunelm Any updates on considering this feature request?

@rkalasky @bryanroth It isn't entirely obvious how to support this.
The patterns require parsing by PatternLayout (which is essentially a collection of PatternConverters).
We cannot re-use any already-present PatternLayout, as there is no guarantee there will be one at all; and even if there is it is not possible to use multiple patterns within a single PatternLayout instance.
So we'd need to create a new PatternLayout instance for each label, which could be done, but I cannot see any simple way of allow this layout to be configured (beyond the pattern), so no custom converters would be possible.
The use of patterns within custom labels would be gated on a flag, something like UsePatternWithinCustomLabels - the default of false would preserve existing behaviour.

Please let me know your views on this, or whether you can see a better way to achieve this.

I would be totally fine with this behavior being gated behind a flag.

My understanding of the log4net internals is novice level, but I don't think custom converters are necessary. I would be happy with the built-in %property{...} (PropertyPatternConverter?) syntax.

We're putting this data into the log message directly today using the above syntax.

Any news on this? It would be required for us to put the %property{log4net:HostName} in one label to filter our logs.

@chrisdunelm Any idea when this change will get published?

@chrisdunelm Brilliant. Thanks for letting me know. Is there a good way to see the release notes for updates to this nuget package?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Watanyou picture Watanyou  路  7Comments

Talento90 picture Talento90  路  6Comments

fagnercarvalho picture fagnercarvalho  路  5Comments

williecohen-google picture williecohen-google  路  9Comments

Eldar-Ahmadov picture Eldar-Ahmadov  路  6Comments