Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
198 views
in Technique[技术] by (71.8m points)

java - log4j2自定义过滤器中的问题(Issue in log4j2 Custom Filter)

I am trying to implement custom filter as mentioned in post Log4j2 custom filter .My lo4j2.xml is as follows

(我正在尝试实现Log4j2自定义过滤器中提到的自定义过滤器。我的lo4j2.xml如下)

<?xml version="1.0" encoding="UTF-8"?>
<!-- Logger configuration when running outside of docker -->
<Configuration  status="trace" packages=“com.rest.server_common.logging">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-5p [%t] %c{1}:%L - %m%n"/>
        </Console>
    </Appenders>
    <Loggers>

        <Root level="DEBUG">

                <com.rest.server_common.logging.MyCustomFilter level="DEBUG"/>

            <AppenderRef ref="Console"/>
        </Root>
    </Loggers>
</Configuration>

When I start my jetty server,I get the error

(当我启动码头服务器时,出现错误)

main ERROR Root contains an invalid element or attribute "com.rest.server_common.logging.MyCustomFilter"

What is the problem here?

(这里有什么问题?)

I have even tried moving filter line

(我什至尝试过移动过滤器线)

<com.rest.server_common.logging.MyCustomFilter level="DEBUG"/>

after Configuration element but I still get the error

(在配置元素之后,但我仍然收到错误)

  ask by Chirayu Chirayu translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

刚要关闭。包装在不同的模块中,因此过滤器未被识别。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...