I want my logs to appear in JSON format. Hence have used logback-logstash-encoder for logging purposes.
I am able to implement most of my usecases except the masking one. The description given in https://github.com/logfellow/logstash-logback-encoder#masking lacks examples of how to do custom implementation of ValueMaskSupplier and ValueMasker's
Can anyone points me to some examples which helps me to understand it better.
Also, I have 2 more queries:
- I am implementing this logstash lib in my spring boot project and all regex patterns to test, against a message will come from configurations i.e application.properties.
in my application.properties, configuration looks like:
log.masking.maskPattern=(\w+@\w+\.\w+)
Now how could i access it below in ${maskPattern}, as its not able to retrieve value:
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="true">
<springProperty scope="context" name="maskingEnabled" source="log.masking.enabled"/>
<springProperty scope="context" name="maskPattern" source="log.masking.maskPattern"/>
<appender name="console_masking" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
<jsonGeneratorDecorator class="net.logstash.logback.mask.MaskingJsonGeneratorDecorator">
<value>${maskPattern}</value>
<path>Message/*</path>
</jsonGeneratorDecorator>
<providers/>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="console_masking"/>
</root>
</configuration>
- My masking usecase says that "value" tag can contains any number of comma seperated regex patterns to be tested against a message. Also it can have a link to a file also, which can contain regex patterns.
Can anyone helps me to understand how can I achieve this usecase as I didn't get any online example to create a custom MaskingJsonGeneratorDecorator.
Please help.