java屏蔽日志_java – 如何屏蔽log4j2日志消息

  • Post author:
  • Post category:java


我正在使用log4j2(版本-2.5),我正在尝试编写一个消息转换器插件,它将掩盖日志消息的一些已知模式.

@Plugin(name = “CustomeMasking”,category = “Converter”)

@ConverterKeys({“m”})

public class MyCustomFilteringLayout extends LogEventPatternConverter {

}

当我使用此插件运行我的Web应用程序时,我看到此警告消息

WARN Converter key ‘m’ is already mapped to ‘class

org.apache.logging.log4j.core.pattern.MessagePatternConverter’. Sorry,

Dave,I can’t let you do that! Ignoring plugin [class

MyCustomFilteringLayout].

在探索log4j2网站后,我找到了这些参考资料.

If multiple Converters specify the same ConverterKeys,then the load

order above determines which one will be used. For example,to

override the %date converter which is provided by the built-in

DatePatternConverter class,you would need to place your plugin in a

JAR file in the CLASSPATH ahead of log4j-core.jar. This is n



版权声明:本文为weixin_39743695原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。