在 Wildfly Logger 中使用多个过滤器规格

Using Multiple filter-spec in Wildfly Logger

我正在使用 Wildfly 10 并且我希望商店服务器登录到一个 json 文件中并带有一些过滤器,这是我的日志:

{
    "msg": "\n[\"getDataMethod\" req. received]\n[password: ***]\n[prop2: value2]]\n",
    "field1": "value1"
}{
    "msg": "\n[call \"getDataMethod\"]\n[password: ***]\n[prop2: value2]]\n",
    "field2": "value2"
}{
    "msg": "full-XML SOAP request",
    "field3": "value3"
}{
    "msg": "\n[\"getDataMethod\" finished...]\n[password: ***]\n[prop2: value2]]\n",
    "field4": "value4"
}

但是这个日志文件有两个问题:

  1. msg 字段包含关键信息(如密码),我想过滤它们。
  2. 有些信息是多余的,我不想存储它们。 (例如,节点包含 "req. received" 或 "call getDataMethod")

为了解决问题 #1,我写了这个 filter-spec 并删除了所有带有 regex:

的桶
<logger category="org.somePackags.MyClass" use-parent-handlers="false">
    <level name="INFO" />
    <filter-spec value="all(match(&quot;\[(.*)\]&quot;),substituteAll(&quot;\[(.*)\]&quot;, &quot; &quot;))" />
    <handlers>
        <handler name="JsonLog" />
    </handlers>
</logger>

现在我想在filter-spec中添加规则来排除问题#2中匹配的节点,我看了FilterExpressions,但我不知道如何写Multiple filter-spec。有什么想法吗?

all 过滤器将处理链中的每个过滤器,如果链中的任何过滤器认为消息不可记录,则不会记录该消息。 allsubstituteAll 过滤器似乎是您应该使用的过滤器。您只需在链中添加更多 substituteAll 个过滤器。

您需要弄清楚的是替换数据的模式。您也可以删除 match,它看起来只是匹配所有内容。