Logback on Jboss duplicates prefixes and new lines when logging

别等时光非礼了梦想. 提交于 2019-11-29 07:38:23
James R. Perkins

WildFly wraps both System.out and System.err in a logger. If you want to use an appender or handler that writes to either stream you need to either use the java.io.FileDescriptor.out (or err) or you need to create a logger category for stdout or stderr as well as a new console-handler to assign to the logger.

/subsystem=logging/pattern-formatter=stdout:add(pattern="%s%n")
/subsystem=logging/console-handler=stdout:add(autoflush=true, target=System.out, named-formatter=stdout, level=ALL)
/subsystem=logging/logger=stdout:add(use-parent-handlers=false, handlers=[stdout], level=ALL)

The above CLI script should remove the default pattern from the logger stdout.

The corresponding representation in standalone.xml looks like this:

<console-handler name="stdout" autoflush="true">
  <level name="ALL"/>
  <formatter>
    <pattern-formatter pattern="%s%n"/>
  </formatter>
</console-handler>
<logger category="stdout" use-parent-handlers="false">
  <level name="ALL"/>
  <handlers>
    <handler name="stdout"/>
  </handlers>
</logger>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!