Logback + Wildfly 8-错误的模式 [英] Logback + Wildfly 8 - incorrect pattern
问题描述
我对logback + wildfly 8配置有问题. 我正在使用简单的ConsoleAppender:
I have a problem with logback + wildfly 8 configuration. I'm using simple ConsoleAppender:
appender("STDOUT", ConsoleAppender) {
encoder(PatternLayoutEncoder) {
pattern = "%d{HH:mm:ss.SSS} [%thread] %-5level %logger{70} - %msg%n"
}
}
logger("com.package.app", INFO)
root(DEBUG, ["STDOUT"])
问题在于,Wildfly还将服务器的日志模式附加到注销消息中. 看起来像:
The problem is that Wildfly appends to logback messages also server's log pattern. It looks like:
11:31:49,954 INFO [stdout] (default task-1) 11:31:49.951 [default task-1] INFO com.package.app.controller.FrontController - message...
如您所见,首先有一个服务器日志模式,然后是注销消息
As You can see, there is a server logs pattern first and then the logback message
如何解决这个问题?
推荐答案
WildFly捕获System.out
和System.err
并将其重定向到记录器.您可以在WildFly中配置名称为stdout
的记录器,将use-parent-handlers
属性设置为false
,并将级别设置为NONE
.这应该禁用System.out
的打印,这意味着它也不会出现在server.log中.
WildFly captures System.out
and System.err
and redirects them to a logger. You could configure a logger in WildFly with the name stdout
, set the use-parent-handlers
attribute to false
and set the level to NONE
. This should disable System.out
from printing which means it will also not appear in the server.log.
也就是说,由于服务器已经提供了ConsoleAppender
,因此我看不到对ConsoleAppender
使用logback的原因.
That said, I don't see a reason to use logback for a ConsoleAppender
since the server already provides one.
这篇关于Logback + Wildfly 8-错误的模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!