JBoss server.log输出自定义 [英] JBoss server.log output customization

查看:218
本文介绍了JBoss server.log输出自定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个servlet,输出我的JBoss 7.1的server.log文件,以便于调试。

I have developed a servlet that outputs the server.log file of my JBoss 7.1 for easier debugging.

我想做的是自定义JBoss的输出并且还显示生成每行输出的战争。

What i want to do is to customize the output of JBoss and also display from which war each line of output is generated.

为了更好地理解这是现在的示例输出:

To understand better this is a sample output right now:

我想要的是输出一些东西来识别哪个部署此输出来自。

What i want is also to output something that will identify from which deployment this output is coming from.

在每个输出中的URL之后,我注意到7001端口之后的数字对于每个部署是不同的,但不知道如何将它与战争文件联系起来....

After the URL in each output i noticed a number after the 7001 port that is different for each deployment, but don't know how to associate that with a war file....

任何人都知道我该怎么做?

Anyone has an idea how i can do that?

提前致谢

更新

我在网上发现了这个 http://java.dzone.com/articles/configuring-logging-jboss 有关配置JBoss但遗憾的是另一个版本。这里解释了如何让log4j为每个部署创建不同的日志文件。这对我来说是最终的解决方案。

I found this on the web http://java.dzone.com/articles/configuring-logging-jboss about configuring JBoss but sadly is for another version. Here it explains how to have log4j create different log files per deployment. That would be the ultimate solution for me.

推荐答案

首先,看来(根据你的日志内容)你是使用System.out.println和System.err.println。

First of all, it seems (from the content of your logs) you are using System.out.println and System.err.println.

如果你将日志切换到slf4j,log4j,commons-logging,当然还有jboss-logging(谢谢James)将能够看到您正在记录的包。

If you switch your logging to slf4j, log4j, commons-logging and of course jboss-logging (thank you James) will be able to see what package you are logging from.

使用正确的日志记录工具后,您可以通过编辑配置文件按类别进行过滤。

Once you use a proper logging facility you can filter by category by editing configuration file.

此外,日志记录将显示更具可读性,即:

Also the logging will show more readable i.e. :

05:21:42,272 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)

我假设你在$ JBOSS_HOME / standalone / configuration / standalone.xml中使用独立配置

I will assume you are using the standalone configuration in $JBOSS_HOME/standalone/configuration/standalone.xml

您需要找到记录子系统

    <subsystem xmlns="urn:jboss:domain:logging:1.1">

并创建一个类型为periodic-rotating-file-handler的新appender:

and create a new appender of type periodic-rotating-file-handler:

        <periodic-rotating-file-handler name="APPLOG1">
            <formatter>
                <pattern-formatter pattern="%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
            </formatter>
            <file relative-to="jboss.server.log.dir" path="applog1.log"/>
            <suffix value=".yyyy-MM-dd"/>
            <append value="true"/>
        </periodic-rotating-file-handler>

然后添加过滤器:

         <logger category="com.yourapppackage">
            <level name="INFO"/>
            <handler name="APPLOG1"/>
        </logger>

应该做的工作。

如果我没有弄错你也可以从管理控制台和CLI创建appender和类别过滤器

If I am not mistaken you can also create appenders and category filters from the administration console and the CLI

问候

这篇关于JBoss server.log输出自定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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