Jboss 记录器验证

Jboss logger validation

如何在 standalone.xml 中配置记录器以便只为一个 class 或包写入消息?

例如:

17:56:41 ERROR [com.google.test] (http-/0.0.0.0:8080-5) Test message Google 
17:56:41 ERROR [com.yaahoo.test] (http-/0.0.0.0:8080-5) Test message Yaahoo

我只想 select 消息 class com.google.test

我的处理程序不工作

<periodic-rotating-file-handler name="FILE" autoflush="true">
                <level name="ERROR"/>
                <filter-spec value="any(match(&quot;[com.google.test]*&quot;))"/>
                <formatter>
                    <named-formatter name="PATTERN"/>
                </formatter>
                <file relative-to="jboss.server.base.dir" path="Error.log"/>
                <suffix value=".yyyy-MM-dd"/>
 </periodic-rotating-file-handler>

您可能需要向该配置添加 <logger> 部分

比如

<subsystem xmlns="urn:jboss:domain:logging:1.1">
            <logger category="com.google.test">
                <level name="ERROR"/>
            </logger>

您已经定义了文件处理程序但是您还没有定义记录器,是吗?你应该在独立 xml:

中添加你的记录器
<logger category="com.google.test" use-parent-handlers="false">
   <level name="ERROR"/>
   <handlers>
       <handler name="FILE"/>
   </handlers>
</logger>

又查官方documentation