[英]Jboss EAP 7 Logging format
我正在使用JBoss EAP7。我正在使用自己的log4j2而不是Jboss日志記錄。 因此,我將它們排除在Jboss-deployment-structure.xml文件中。
<deployment>
<exclude-subsystems>
<subsystem name="logging" />
</exclude-subsystems>
<!--
Prevent that the server add automatically dependencies -->
<!-- Exclude all logging dependencies so we can use log4j2 -->
<exclusions>
<module name="org.apache.commons.logging" />
<module name="org.apache.log4j" />
<module name="org.jboss.logging" />
<module name="org.jboss.logging.jul-to-slf4j-stub" />
<module name="org.jboss.logmanager" />
<module name="org.jboss.logmanager.log4j" />
<module name="org.slf4j" />
<module name="org.slf4j.impl" />
</exclusions>
</deployment>
在我的log4j2.xml文件中,我提到了以下模式布局。
<Console name="STDOUT" target="SYSTEM_OUT">
<PatternLayout pattern="%p|%d|%c|%m|%n" />
</Console>
但是,當我最初啟動應用程序時,會出現一個類加載,其中日志可以正確打印,如下所示。
DEBUG|2017-08-08 13:20:26,993|Default.com.test.StartClass|deleting directory: C:\eclipse\workspace\WEB-INF\templates
但是稍后,當Jboss服務器開始加載其子系統時,它將在我的實際模式之前添加stdout並添加其他內容。
13:39:06,997 INFO [stdout] (ServerService Thread Pool -- 87) INFO|2017-08-08 13:39:06,997|Default.com.test.AppXmlUnmarshaller|Unmarshalling took 342 milliseconds.
我不為什么在排除子系統之后也采用這種模式布局。 請幫助我解決此問題。
提前致謝。
JBoss EAP在記錄器中同時包裝了stdout
和stderr
。 我假設您正在使用ConsoleAppender
,它將寫入stdout
。 如果要避免使用標准模式前綴,則需要創建一個單獨的console-handler
並為其分配僅打印消息的模式。 然后創建一個stdout
記錄器,並use-parent-handlers
設置為false
為其分配新的console-handler
use-parent-handlers
。 類似於以下CLI命令的命令應該可以執行此操作。
/subsystem=logging/pattern-formatter=msg-only-format:add(pattern="%s%n")
/subsystem=logging/console-handler=stdout:add(named-formatter=msg-only-format, autoflush=true, target=System.out)
/subsystem=logging/logger=stdout:add(handlers=[stdout], use-parent-handlers=false)
如果您要排除日志子系統,則也僅是一個FYI,就不需要那些依賴項排除。 日志記錄子系統是將那些依賴項添加到您的部署中的工具。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.