如何将 PrettyPrintingJsonGeneratorDecorator 和 MaskingJsonGeneratorDecorator 组合在一起?
How can I combine PrettyPrintingJsonGeneratorDecorator and MaskingJsonGeneratorDecorator together?
我已尝试配置 logstash-logback-encoder
版本 6.4
以将漂亮的印刷品 JSON 打印为
<appender name="consoleAsJSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeCallerData>true</includeCallerData>
<jsonGeneratorDecorator class="net.logstash.logback.decorate.PrettyPrintingJsonGeneratorDecorator"/>
</encoder>
</appender>
输出是预期的 pretty print
。然后我向前迈出一步,使用掩码进行配置
<appender name="consoleAsJSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeCallerData>true</includeCallerData>
<jsonGeneratorDecorator class="net.logstash.logback.mask.MaskingJsonGeneratorDecorator">
<defaultMask>XXXX</defaultMask>
<path>password</path>
</jsonGeneratorDecorator>
</encoder>
</appender>
输出也是预期的 marked
。
无论如何,当我将这两个结合在一起时,它只会做一件事,pretty print
或masked
。
<appender name="consoleAsJSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeCallerData>true</includeCallerData>
<jsonGeneratorDecorator class="net.logstash.logback.decorate.PrettyPrintingJsonGeneratorDecorator"/>
<jsonGeneratorDecorator class="net.logstash.logback.mask.MaskingJsonGeneratorDecorator">
<defaultMask>XXXX</defaultMask>
<path>password</path>
</jsonGeneratorDecorator>
</encoder>
</appender>
它只做 masked
,但是 not pretty print
。
<appender name="consoleAsJSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeCallerData>true</includeCallerData>
<jsonGeneratorDecorator class="net.logstash.logback.mask.MaskingJsonGeneratorDecorator">
<defaultMask>XXXX</defaultMask>
<path>password</path>
</jsonGeneratorDecorator>
<jsonGeneratorDecorator class="net.logstash.logback.decorate.PrettyPrintingJsonGeneratorDecorator"/>
</encoder>
</appender>
它只做 pretty print
,但是 not masked
。
如何将 PrettyPrintingJsonGeneratorDecorator
和 MaskingJsonGeneratorDecorator
组合在一起?能否请您帮忙指教一下?
使用 CompositeJsonGeneratorDecorator,像这样:
<appender name="consoleAsJSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeCallerData>true</includeCallerData>
<jsonGeneratorDecorator class="net.logstash.logback.decorate.CompositeJsonGeneratorDecorator">
<decorator class="net.logstash.logback.decorate.PrettyPrintingJsonGeneratorDecorator"/>
<decorator class="net.logstash.logback.mask.MaskingJsonGeneratorDecorator">
<defaultMask>XXXX</defaultMask>
<path>password</path>
</decorator>
</jsonGeneratorDecorator>
</encoder>
</appender>
我已尝试配置 logstash-logback-encoder
版本 6.4
以将漂亮的印刷品 JSON 打印为
<appender name="consoleAsJSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeCallerData>true</includeCallerData>
<jsonGeneratorDecorator class="net.logstash.logback.decorate.PrettyPrintingJsonGeneratorDecorator"/>
</encoder>
</appender>
输出是预期的 pretty print
。然后我向前迈出一步,使用掩码进行配置
<appender name="consoleAsJSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeCallerData>true</includeCallerData>
<jsonGeneratorDecorator class="net.logstash.logback.mask.MaskingJsonGeneratorDecorator">
<defaultMask>XXXX</defaultMask>
<path>password</path>
</jsonGeneratorDecorator>
</encoder>
</appender>
输出也是预期的 marked
。
无论如何,当我将这两个结合在一起时,它只会做一件事,pretty print
或masked
。
<appender name="consoleAsJSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeCallerData>true</includeCallerData>
<jsonGeneratorDecorator class="net.logstash.logback.decorate.PrettyPrintingJsonGeneratorDecorator"/>
<jsonGeneratorDecorator class="net.logstash.logback.mask.MaskingJsonGeneratorDecorator">
<defaultMask>XXXX</defaultMask>
<path>password</path>
</jsonGeneratorDecorator>
</encoder>
</appender>
它只做 masked
,但是 not pretty print
。
<appender name="consoleAsJSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeCallerData>true</includeCallerData>
<jsonGeneratorDecorator class="net.logstash.logback.mask.MaskingJsonGeneratorDecorator">
<defaultMask>XXXX</defaultMask>
<path>password</path>
</jsonGeneratorDecorator>
<jsonGeneratorDecorator class="net.logstash.logback.decorate.PrettyPrintingJsonGeneratorDecorator"/>
</encoder>
</appender>
它只做 pretty print
,但是 not masked
。
如何将 PrettyPrintingJsonGeneratorDecorator
和 MaskingJsonGeneratorDecorator
组合在一起?能否请您帮忙指教一下?
使用 CompositeJsonGeneratorDecorator,像这样:
<appender name="consoleAsJSON" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<includeCallerData>true</includeCallerData>
<jsonGeneratorDecorator class="net.logstash.logback.decorate.CompositeJsonGeneratorDecorator">
<decorator class="net.logstash.logback.decorate.PrettyPrintingJsonGeneratorDecorator"/>
<decorator class="net.logstash.logback.mask.MaskingJsonGeneratorDecorator">
<defaultMask>XXXX</defaultMask>
<path>password</path>
</decorator>
</jsonGeneratorDecorator>
</encoder>
</appender>