log4j2 中 DenyAllFilter 的等价物是什么

What is the equivalent of DenyAllFilter in log4j2

我正在将应用程序从 log4j 迁移到 log4j2

下面的代码片段 log4j 相关,并且添加了过滤器 DenyAllFilter

<appender name="TEST_FILE" class="org.apache.log4j.RollingFileAppender">
  ...
  ...
  <filter class="com.test.it.ModeFilter">
      <param name="Mode" value="Test" />
      <param name="Deny" value="false" />
  </filter>
  <filter class="org.apache.log4j.varia.DenyAllFilter"/>
</appender>

DenyAllFilter 也应该在 log4j2 中定义吗?如果是这样,那么 log4j2 中的 DenyAllFilter 的等效项是什么,以便可以将其添加到 log4j2.xml 下的 RollingFile 中,如下所述。

<RollingFile="TEST_FILE" other sttributes ...>
  ...
  ...
<ModeFilter name="ModeFilter" other attributes ... />
??? what is the equivalent of DenyAllFilter???

请帮忙。谢谢。

根据 docs,DenyAllFilter 可用于从默认 "accept all unless instructed otherwise" 过滤行为切换到 "deny all unless instructed otherwise" 行为。

在 Log4j 2 中没有与此直接等效的内容。由于无论如何您都需要将自定义 ModeFilter 重写为 Log4j 2 plugin,因此您可能想要更改此过滤器的 accept/reject 条件.