/hazelcast-documentation/src/main/docbook/manual/content/config/Logging.xml
https://bitbucket.org/gabral6_gmailcom/hazelcast · XML · 137 lines · 116 code · 6 blank · 15 comment · 0 complexity · b9f345f091f967e359584bb55356548c MD5 · raw file
- <?xml version='1.0' encoding='UTF-8'?>
- <!--
- ~ Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
- <sect1 xml:id="Logging" version="5.0" xmlns="http://docbook.org/ns/docbook"
- xmlns:xi="http://www.w3.org/2001/XInclude"
- xmlns:xlink="http://www.w3.org/1999/xlink"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd
- http://www.w3.org/1999/xlink http://www.w3.org/1999/xlink.xsd">
- <title>Logging Configuration</title>
- <para>Hazelcast has a flexible logging configuration and doesn't depend on any logging framework except JDK logging.
- It has in-built adaptors for a number of logging frameworks
- and also supports custom loggers by providing logging interfaces.
- </para>
- <para>To use built-in adaptors you should set
- <code>hazelcast.logging.type</code>
- property to one of
- predefined types below.
- <itemizedlist>
- <listitem>
- <para><emphasis role="bold">jdk:</emphasis>JDK logging (default)
- </para>
- </listitem>
- <listitem>
- <para><emphasis role="bold">log4j:</emphasis>Log4j
- </para>
- </listitem>
- <listitem>
- <para><emphasis role="bold">slf4j:</emphasis>Slf4j
- </para>
- </listitem>
- <listitem>
- <para><emphasis role="bold">none:</emphasis>disable logging
- </para>
- </listitem>
- </itemizedlist>
- You can set
- <code>hazelcast.logging.type</code>
- through configuration xml, configuration API or JVM system property.
- <itemizedlist>
- <listitem>
- <para>
- <emphasis role="bold">Configuration xml</emphasis>
- </para>
- <para>
- <programlisting language="xml">
- <hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config
- http://www.hazelcast.com/schema/config/hazelcast-config-2.5.xsd"
- xmlns="http://www.hazelcast.com/schema/config"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- ....
- <properties>
- <property name="hazelcast.logging.type">jdk</property>
- ....
- </properties>
- </hazelcast></programlisting>
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis role="bold">Configuration API</emphasis>
- </para>
- <para>
- <programlisting language="java">
- Config cfg = new Config() ;
- cfg.setProperty("hazelcast.logging.type", "log4j");
- </programlisting>
- </para>
- </listitem>
- <listitem>
- <para>
- <emphasis role="bold">System Property</emphasis>
- </para>
- <para>
- <orderedlist>
- <listitem>
- <para>Using JVM parameter:
- <literal>java -Dhazelcast.logging.type=slf4j</literal>
- </para>
- </listitem>
- <listitem>
- <para>Using System class:
- <literal>System.setProperty("hazelcast.logging.type", "none");</literal>
- </para>
- </listitem>
- </orderedlist>
- </para>
- </listitem>
- </itemizedlist>
- </para>
- <para>To use custom logging feature you should implement
- <code>com.hazelcast.logging.LoggerFactory</code>
- and
- <code>com.hazelcast.logging.ILogger</code>
- interfaces and set system property
- <literal>hazelcast.logging.class</literal>
- to
- your custom
- <code>LoggerFactory</code>
- class name.
- <programlisting language="java">java -Dhazelcast.logging.class=foo.bar.MyLoggingFactory</programlisting>
- </para>
- <para>
- You can also listen to logging events generated by Hazelcast runtime by registering <literal>LogListener</literal>s to<literal>LoggingService</literal>.
- <programlisting language="java">
- LogListener listener = new LogListener() {
- public void log(LogEvent logEvent) {
- // do something
- }
- }
- LoggingService loggingService = Hazelcast.getLoggingService();
- loggingService.addLogListener(Level.INFO, listener):
- </programlisting>
- Through the
- <literal>LoggingService</literal>
- you can get the current used ILogger implementation and log your own messages too.
- </para>
- </sect1>