154 lines
7.1 KiB
XML
154 lines
7.1 KiB
XML
<?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 Attribution–Share 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. -->
|
||
<!-- ============================================================================= -->
|
||
|
||
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
||
<!ENTITY % BOOK_ENTITIES SYSTEM "HornetQ_User_Manual.ent">
|
||
%BOOK_ENTITIES;
|
||
]>
|
||
<chapter id="logging">
|
||
<title>Logging</title>
|
||
<para>HornetQ uses the JBoss Logging framework to do its logging and is configurable via the <literal>logging.properties</literal>
|
||
file found in the configuration directories. This is configured by Default to log to both the console and to a file.</para>
|
||
<para>There are 6 loggers available which are as follows:</para>
|
||
<table frame="topbot" border="2">
|
||
<title>Global Configuration Properties</title>
|
||
<tgroup cols="2">
|
||
<colspec colname="c1" colnum="1"/>
|
||
<colspec colname="c2" colnum="2"/>
|
||
<thead>
|
||
<row>
|
||
<entry>Logger</entry>
|
||
<entry>Logger Description</entry>
|
||
</row>
|
||
</thead>
|
||
<tbody>
|
||
<row>
|
||
<entry>org.jboss.logging</entry>
|
||
<entry>Logs any calls not handled by the HornetQ loggers</entry>
|
||
</row>
|
||
<row>
|
||
<entry>org.hornetq.core.server</entry>
|
||
<entry>Logs the core server</entry>
|
||
</row>
|
||
<row>
|
||
<entry>org.hornetq.utils</entry>
|
||
<entry>Logs utility calls</entry>
|
||
</row>
|
||
<row>
|
||
<entry>org.hornetq.journal</entry>
|
||
<entry>Logs Journal calls</entry>
|
||
</row>
|
||
<row>
|
||
<entry>org.hornetq.jms</entry>
|
||
<entry>Logs JMS calls</entry>
|
||
</row>
|
||
<row>
|
||
<entry>org.hornetq.integration.bootstrap</entry>
|
||
<entry>Logs bootstrap calls</entry>
|
||
</row>
|
||
</tbody>
|
||
</tgroup>
|
||
<para>you can configure the levels on these loggers independently in the appropriate <literal>logging.properties</literal>
|
||
file</para>
|
||
</table>
|
||
<section>
|
||
<title>Logging in a client or with an Embedded server</title>
|
||
<para>
|
||
Firstly, if you want to enable logging on the client side you need to include the jboss logging jars in your library.
|
||
If you are using the distribution make sure the jnp-client.jar is included or if you are using maven add the following
|
||
dependencies.
|
||
<programlisting>
|
||
<dependency>
|
||
<groupId>org.jboss.naming</groupId>
|
||
<artifactId>jnp-client</artifactId>
|
||
<version>5.0.5.Final</version>
|
||
<exclusions>
|
||
<exclusion>
|
||
<groupId>org.jboss.logging</groupId>
|
||
<artifactId>jboss-logging-spi</artifactId>
|
||
</exclusion>
|
||
</exclusions>
|
||
</dependency>
|
||
<dependency>
|
||
<groupId>org.jboss.logmanager</groupId>
|
||
<artifactId>jboss-logmanager</artifactId>
|
||
<version>1.3.1.Final</version>
|
||
</dependency>
|
||
<dependency>
|
||
<groupId>org.hornetq</groupId>
|
||
<artifactId>hornetq-core-client</artifactId>
|
||
<version>2.3.0.Final</version>
|
||
</dependency></programlisting>
|
||
The first dependency <literal>jnp-client</literal> is not actually needed for logging, however this is needed for
|
||
using JNDI and imports a previous version JBoss logging which needs to be excluded
|
||
</para>
|
||
<para>
|
||
There are 2 properties you need to set when starting your java program, the first is to set the Log Manager to use
|
||
the JBoss Log Manager, this is done by setting the <literal>-Djava.util.logging.manager</literal> property i.e.
|
||
<literal>-Djava.util.logging.manager=org.jboss.logmanager.LogManager</literal>
|
||
</para>
|
||
<para>
|
||
The second is to set the location of the logging.properties file to use, this is done via the <literal>-Dlogging.configuration</literal>
|
||
for instance <literal>-Dlogging.configuration=file:///home/user/projects/myProject/logging.properties</literal>.
|
||
<note>The value for this needs to be valid URL</note>
|
||
</para>
|
||
<para>
|
||
The following is a typical <literal>logging.properties for a client</literal>
|
||
<programlisting>
|
||
# Root logger option
|
||
loggers=org.jboss.logging,org.hornetq.core.server,org.hornetq.utils,org.hornetq.journal,org.hornetq.jms,org.hornetq.ra
|
||
|
||
# Root logger level
|
||
logger.level=INFO
|
||
# HornetQ logger levels
|
||
logger.org.hornetq.core.server.level=INFO
|
||
logger.org.hornetq.utils.level=INFO
|
||
logger.org.hornetq.jms.level=DEBUG
|
||
|
||
# Root logger handlers
|
||
logger.handlers=FILE,CONSOLE
|
||
|
||
# Console handler configuration
|
||
handler.CONSOLE=org.jboss.logmanager.handlers.ConsoleHandler
|
||
handler.CONSOLE.properties=autoFlush
|
||
handler.CONSOLE.level=FINE
|
||
handler.CONSOLE.autoFlush=true
|
||
handler.CONSOLE.formatter=PATTERN
|
||
|
||
# File handler configuration
|
||
handler.FILE=org.jboss.logmanager.handlers.FileHandler
|
||
handler.FILE.level=FINE
|
||
handler.FILE.properties=autoFlush,fileName
|
||
handler.FILE.autoFlush=true
|
||
handler.FILE.fileName=hornetq.log
|
||
handler.FILE.formatter=PATTERN
|
||
|
||
# Formatter pattern configuration
|
||
formatter.PATTERN=org.jboss.logmanager.formatters.PatternFormatter
|
||
formatter.PATTERN.properties=pattern
|
||
formatter.PATTERN.pattern=%d{HH:mm:ss,SSS} %-5p [%c] %s%E%n</programlisting>
|
||
</para>
|
||
</section>
|
||
<section>
|
||
<title>Logging With The JBoss Application Server</title>
|
||
<para>When HornetQ is deployed within the JBoss Application Server version 7.x or above then
|
||
it will still use JBoss Logging, refer to the AS7 documentation on how to configure AS7 logging.</para>
|
||
</section>
|
||
</chapter>
|