如何在JBoss中禁用对标准输出的捕获? [英] How to disable capture of std-out in JBoss?

查看:238
本文介绍了如何在JBoss中禁用对标准输出的捕获?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用JBoss EAP 6.4(我猜是AS 7.x).

Using JBoss EAP 6.4 (AS 7.x I guess).

默认情况下,JBoss的日志记录服务正在将所有应用程序输出捕获到stdout(可能是stderr)并将其包装在自己的基于log4j的日志中.在本地运行时,我想完全禁用此功能(烦人的) 1 ,但是我在Interwebs上找到的引用都不起作用,或者不适用于旧版本的JBoss.我尝试排除jboss-deployment-structure配置中的所有可能的日志记录框架,将-Dorg.jboss.logging.per-deployment=false作为系统属性传递,但JBoss仍然捕获标准输出.

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.

如何在此版本的JBoss中禁用它?

How can I disable it in this version of JBoss?

[1]如果您必须知道原因,那是因为我们通过logback进行了详细的日志记录配置,并且当在IDE中本地运行时希望能够在不使用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.

推荐答案

在入口点进行了硬编码,以捕获stdoutstderr.这样做是为了将两个流都写入已定义的日志处理程序.因此,周围没有真正干净的方法.但是,有一些方法可以使它至少看起来更好一些.

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.

您可以创建一个新的console-handler并定义一个stdout记录器,以确保仅编写简单消息.

You can create a new console-handler and define a stdout logger to ensure only the simple message is written though.

以下是一些CLI命令,可将名为stdout的记录器配置为仅打印接收到的消息.

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])

注意:可能是我的测试logback.xml配置,但是我必须对plain-formatter使用%s%n模式.

Note: It could be my test logback.xml configuration, but I had to use a pattern of %s%n for the plain-formatter.

我唯一想到的另一种选择是编写自己的logback ConsoleAppender,它基于java.io.FileOutputStream.out而不是使用System.out来创建输出流.

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.

这篇关于如何在JBoss中禁用对标准输出的捕获?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆