Search code examples
javasonarqubeslf4j

Any idea to prevent specific attribute to appear in the logs?


I'm looking for a way to prevent some sensitive data from being logged.

Ideally i would like to prevent / capture things like

String sensitive = "";
log.info ("This should be prevented or caught by something : {} ", sensitive);

this post is a bit of a longshot, I'm willing to investigate on any lead. annotation, new types, Sonar Rules, logger hacking etc...

thx for your brainstorming :)

guillaume


Solution

  • Create custom type for it.

    Make sure that toString doesn't return actual content.