JBoss AS 7 配置日志记录到 Syslog Appender [英] JBoss AS 7 configure logging to Syslog Appender
问题描述
在以前版本的 Jboss 中,我能够在 jboss-log4j.xml 中使用以下配置来配置 SYSLOG appender:
In a previous version of Jboss I was able to configure a SYSLOG appender with the following configuration in jboss-log4j.xml:
<appender name="SYSLOG" class="org.apache.log4j.net.SyslogAppender">
<errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="Facility" value="LOCAL7"/>
<param name="FacilityPrinting" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ABSOLUTE},%c{1}] %m%n"/>
</layout>
</appender>
现在我已经升级到 Jboss AS 7,看起来这应该放在 $JBOSS_HOME/standalone/configuration/standalone.xml
中,但语法不同.
Now I've upgraded to Jboss AS 7 and it seems like this should go in the $JBOSS_HOME/standalone/configuration/standalone.xml
but the syntax is different.
我的问题是:如何配置 Jboss AS 7 以使用 SYSLOG appender?
My question is: How do I configure Jboss AS 7 to use a SYSLOG appender?
推荐答案
在 JBoss AS 7 中不再使用 log4j,因为没有 syslog appender.您必须找到或开发自定义 java.util.logging.Handler
如果你想要类似的东西.
log4j is no longer used in JBoss AS 7 there for there is no syslog appender. You would have to find or develop a custom java.util.logging.Handler
if you want something similar.
创建处理程序后,最好将其设为模块.假设处理程序名为 com.example.logging.SysLogHandler
.在 $JBOSS_HOME/modules
中创建一个名为 com/example/logging/main
的目录.在该目录中放置您的库并创建一个 module.xml
文件,请参阅另一个模块的示例.
Once the handler is created it's probably best to make it a module. Let's say the handler was called com.example.logging.SysLogHandler
. In $JBOSS_HOME/modules
create a directory called com/example/logging/main
. In that directory place your library and create an module.xml
file, see another module for an example.
module.xml 示例:
module.xml example:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.example.logging">
<resources>
<resource-root path="sys-log.jar"/>
</resources>
<dependencies>
<!-- Insert any dependencies here like the example below -->
<!-- <module name="org.jboss.logmanager"/> -->
</dependencies>
</module>
您现在可以编辑 standalone.xml
以添加自定义处理程序.
You can now edit the standalone.xml
to add a custom handler.
<subsystem xmlns="urn:jboss:domain:logging:1.1">
...
<!-- A syslog handler -->
<custom-handler name="syslog" class="com.example.logging.SysLogHandler" module="com.example.logging">
<level name="INFO"/>
<formatter>
<pattern-formatter pattern="%d{MMM dd HH:mm:ss} %-5p [%c] (%t) %s%n"/>
</formatter>
<properties>
<!-- Set any properties that can accessed through setter methods -->
<property name="autoFlush" value="true"/>
</properties>
</custom-handler>
...
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
<handler name="syslog"/>
</handlers>
</root-logger>
</subsystem>
这篇关于JBoss AS 7 配置日志记录到 Syslog Appender的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!