You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Currently there is not a great way to query for specific event specific fields from an encoder. It's also tough to extract data from structured arguments/markers from a LoggingEvent because getFieldName/getFieldValue is protected and the only reliable way to pull out the field name and value is to fake out a JSONGenerator:
FakeJsonGenerator gen = new FakeJsonGenerator();
structuredArgument.writeTo(gen);
String name = gen.getFieldName();
Object value = gen.getFieldValue();
There are valid use cases for querying event specific fields, such as:
Use in evaluator, which would allow filtering on the presence/absence of event specific fields
Presentation of specific event specific field data in encoders, i.e. rendering "userId" if it exists
Special treatment of event specific fields i.e. highlighting on specific name/value pairs
Transformation of complex structured data, i.e. rendering a specific field from an argument containing a complex ObjectNode.
Inside an evaluator you could get the title specifically using:
public Optional<String> getTitle(ILoggingEvent event) {
return StructuredArguments.findString(event, "$.store.book[0].title");
}
Using JSONPath would also be helpful in determining masking, for example masking by index.
Additional context
I've implemented a JSONPath API here in Echopraxia, but it's only really useful before logging. I can add conditions and query fields up to the point where it's time to write to the SLF4J Logger, but after that it's harder to get it from the logging event.
The text was updated successfully, but these errors were encountered:
wsargent
changed the title
Converters using JSONPath to query StructuredArgument/Marker
Query StructuredArgument/Marker using JSONPath
Feb 7, 2023
Is your feature request related to a problem? Please describe.
Currently there is not a great way to query for specific event specific fields from an encoder. It's also tough to extract data from structured arguments/markers from a LoggingEvent because getFieldName/getFieldValue is protected and the only reliable way to pull out the field name and value is to fake out a JSONGenerator:
There are valid use cases for querying event specific fields, such as:
Describe the solution you'd like
Say that you have a structured logging statement:
It would be nice to be able to query the structured argument using JSONPath through a custom converter:
Extraction could be provided through JSONPath API on the backend, for example rendering a store:
Inside an evaluator you could get the title specifically using:
Using JSONPath would also be helpful in determining masking, for example masking by index.
Additional context
I've implemented a JSONPath API here in Echopraxia, but it's only really useful before logging. I can add conditions and query fields up to the point where it's time to write to the SLF4J Logger, but after that it's harder to get it from the logging event.
The text was updated successfully, but these errors were encountered: