logfellow / logstash-logback-encoder

Logback JSON encoder and appenders
Apache License 2.0
2.44k stars 407 forks source link

Option to serialize nonStructuredArguments using toString #987

Open schmidti159 opened 1 year ago

schmidti159 commented 1 year ago

As described in https://github.com/logfellow/logstash-logback-encoder/issues/304 all arguments are serialized using jackson when includeNonStructuredArguments=true is set.

This might expose sensitive data through logging as not all developers might be aware that the complete object is serialized.

It would be great to have a separate configuration like serializeNonStructuredArguments (default true). If it is set to false the arguments will not be serialized with jackson but toString will be used.

This enables the opportunity to enable includeNonStructuredArguments=true for legacy code bases where it is not feasible to analyze all existing log messages.

Does it make sense to you to add this to this lib? If yes, I could provide a PR.

philsttr commented 3 months ago

Makes sense. Contributions welcome.

I'd prefer the new flag to be named writeNonStructuredArgumentsAsString, default false.