activemq-artemis/docs/user-manual/zh/logging.xml

47 lines
4.1 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8"?>
<!-- ============================================================================= -->
<!-- Copyright © 2009 Red Hat, Inc. and others. -->
<!-- -->
<!-- The text of and illustrations in this document are licensed by Red Hat under -->
<!-- a Creative Commons AttributionShare Alike 3.0 Unported license ("CC-BY-SA"). -->
<!-- -->
<!-- An explanation of CC-BY-SA is available at -->
<!-- -->
<!-- http://creativecommons.org/licenses/by-sa/3.0/. -->
<!-- -->
<!-- In accordance with CC-BY-SA, if you distribute this document or an adaptation -->
<!-- of it, you must provide the URL for the original version. -->
<!-- -->
<!-- Red Hat, as the licensor of this document, waives the right to enforce, -->
<!-- and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent -->
<!-- permitted by applicable law. -->
<!-- ============================================================================= -->
<chapter id="logging">
<title>日志Logging</title>
<para>HornetQ有自己的独立的日志系统不依赖于任何其它的日志框架。在默认情况下所有HornetQ的日志将输入到
标准的<ulink
url="http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/">JDK日志系统</ulink>
即JULJava Util Logging。服务器在默认条件下读取config目录下的
<literal>logging.properties</literal>文件做为JUL的配置文件。它配置了使用HornetQ自己的格式化
方法将日志输出到屏幕终端Console及文件中。请访问Sun公司的相关网址来进一步了解如何配置使用JUL。</para>
<para>你可以通过编程或定义系统变量的方法来配置不同的日志代理Logging Delegate</para>
<para>采用编程方法,只需要调用方法:
<programlisting>org.apache.activemq6.core.logging.Logger.setDelegateFactory(new Log4jLogDelegateFactory())</programlisting></para>
<para>其中<literal>Log4jLogDelegateFactory</literal>实现了<literal
>org.apache.activemq6.spi.core.logging.LogDelegateFactory </literal>接口。</para>
<para>如果要使用系统变量方法,则需要设置变量<literal
>org.apache.activemq6.logger-delegate-factory-class-name</literal>为相应的代理工厂,即
<programlisting>-Dorg.apache.activemq6.logger-delegate-factory-class-name=org.apache.activemq6.integration.logging.Log4jLogDelegateFactory</programlisting></para>
<para>上面的例子可以看出HornetQ提供了一些代理工厂以方便用户使用它们是<orderedlist
><listitem><para>org.apache.activemq6.core.logging.impl.JULLogDelegateFactory - 默认的JUL日志代理工厂。</para>
</listitem><listitem><para>org.apache.activemq6.integration.logging.Log4jLogDelegateFactory
- Log4J的日志代理工厂。</para></listitem></orderedlist></para>
<para>如果在客户端使用JUL代理注意要提供<literal>logging.properties</literal>文件,并且在客户端启动之前设置<literal
>java.util.logging.config.file</literal>属性。</para>
<section>
<title>与JBoss应用服务器日志的关系</title>
<para>当HornetQ部署到JBoss应用服务器版本5.x或以上时虽然HornetQ仍然使用JUL但是所有的日志输出被重定向到
JBoss logger。请参阅相关的JBoss文档来了解更多的信息。如果是以前版本的JBoss则必需指定你所需要的日志代理。</para>
</section>
</chapter>