问题
Using JBoss EAP 6.4 (AS 7.x I guess).
By default, JBoss' logging service is capturing all application output to stdout (and presumably stderr) and wrapping it in its own log4j-based logs. When running locally I want to totally disable this (annoying) feature1, but the references I've found on the Interwebs all either don't work or are for older versions of JBoss. I've tried excluding every possible logging framework in the jboss-deployment-structure
configuration, passing -Dorg.jboss.logging.per-deployment=false
as a system property, but still JBoss captures stdout.
How can I disable it in this version of JBoss?
[1] If you must know the reason, it's because we have detailed logging configuration via logback and when running locally in an IDE want to be able to see and control that log output in the console without JBoss' logging service getting in the way.
回答1:
It's hard-coded in the entry points to capture stdout
and stderr
. This is done so both streams are written to the defined log handlers. Because of this there is no real clean way around it. However there are ways to make it at least look a little better.
You can create a new console-handler
and define a stdout
logger to ensure only the simple message is written though.
Here are some CLI commands to configure a logger named stdout
to just print the message it receives.
/subsystem=logging/pattern-formatter=plain-formatter:add(pattern="%s")
/subsystem=logging/console-handler=plain-console:add(autoflush=true, target=System.out, named-formatter=plain-formatter)
/subsystem=logging/logger=stdout:add(use-parent-handlers=false, handlers=[plain-console])
Note: It could be my test logback.xml configuration, but I had to use a pattern of %s%n
for the plain-formatter
.
The only other option I can think of would be to write your own logback ConsoleAppender
that creates an output stream based on java.io.FileOutputStream.out
rather than using System.out
.
来源:https://stackoverflow.com/questions/37190004/how-to-disable-capture-of-std-out-in-jboss