PageRenderTime 28ms CodeModel.GetById 16ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/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
  1<?xml version='1.0' encoding='UTF-8'?>
  2<!--
  3  ~ Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
  4  ~
  5  ~ Licensed under the Apache License, Version 2.0 (the "License");
  6  ~ you may not use this file except in compliance with the License.
  7  ~ You may obtain a copy of the License at
  8  ~
  9  ~ http://www.apache.org/licenses/LICENSE-2.0
 10  ~
 11  ~ Unless required by applicable law or agreed to in writing, software
 12  ~ distributed under the License is distributed on an "AS IS" BASIS,
 13  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  ~ See the License for the specific language governing permissions and
 15  ~ limitations under the License.
 16  -->
 17
 18<sect1 xml:id="Logging" version="5.0" xmlns="http://docbook.org/ns/docbook"
 19       xmlns:xi="http://www.w3.org/2001/XInclude"
 20       xmlns:xlink="http://www.w3.org/1999/xlink"
 21       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 22       xsi:schemaLocation="http://docbook.org/ns/docbook http://www.docbook.org/xml/5.0/xsd/docbook.xsd
 23       http://www.w3.org/1999/xlink http://www.w3.org/1999/xlink.xsd">
 24    <title>Logging Configuration</title>
 25    <para>Hazelcast has a flexible logging configuration and doesn't depend on any logging framework except JDK logging.
 26        It has in-built adaptors for a number of logging frameworks
 27        and also supports custom loggers by providing logging interfaces.
 28    </para>
 29    <para>To use built-in adaptors you should set
 30        <code>hazelcast.logging.type</code>
 31        property to one of
 32        predefined types below.
 33        <itemizedlist>
 34            <listitem>
 35                <para><emphasis role="bold">jdk:</emphasis>JDK logging (default)
 36                </para>
 37            </listitem>
 38            <listitem>
 39                <para><emphasis role="bold">log4j:</emphasis>Log4j
 40                </para>
 41            </listitem>
 42            <listitem>
 43                <para><emphasis role="bold">slf4j:</emphasis>Slf4j
 44                </para>
 45            </listitem>
 46            <listitem>
 47                <para><emphasis role="bold">none:</emphasis>disable logging
 48                </para>
 49            </listitem>
 50        </itemizedlist>
 51
 52        You can set
 53        <code>hazelcast.logging.type</code>
 54        through configuration xml, configuration API or JVM system property.
 55        <itemizedlist>
 56            <listitem>
 57                <para>
 58                    <emphasis role="bold">Configuration xml</emphasis>
 59                </para>
 60                <para>
 61                    <programlisting language="xml">
 62&lt;hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config 
 63    http://www.hazelcast.com/schema/config/hazelcast-config-2.5.xsd"
 64    xmlns="http://www.hazelcast.com/schema/config"
 65    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
 66
 67    ....
 68
 69    &lt;properties&gt;
 70        &lt;property name="hazelcast.logging.type"&gt;jdk&lt;/property&gt;
 71        ....
 72    &lt;/properties&gt;
 73&lt;/hazelcast&gt;</programlisting>
 74                </para>
 75            </listitem>
 76            <listitem>
 77                <para>
 78                    <emphasis role="bold">Configuration API</emphasis>
 79                </para>
 80                <para>
 81                    <programlisting language="java">
 82Config cfg = new Config() ;
 83cfg.setProperty("hazelcast.logging.type", "log4j");
 84                    </programlisting>
 85                </para>
 86            </listitem>
 87            <listitem>
 88                <para>
 89                    <emphasis role="bold">System Property</emphasis>
 90                </para>
 91                <para>
 92                    <orderedlist>
 93                        <listitem>
 94                            <para>Using JVM parameter:
 95                                <literal>java -Dhazelcast.logging.type=slf4j</literal>
 96                            </para>
 97                        </listitem>
 98                        <listitem>
 99                            <para>Using System class:
100                                <literal>System.setProperty("hazelcast.logging.type", "none");</literal>
101                            </para>
102                        </listitem>
103                    </orderedlist>
104                </para>
105            </listitem>
106        </itemizedlist>
107    </para>
108
109    <para>To use custom logging feature you should implement
110        <code>com.hazelcast.logging.LoggerFactory</code>
111        and
112        <code>com.hazelcast.logging.ILogger</code>
113        interfaces and set system property
114        <literal>hazelcast.logging.class</literal>
115        to
116        your custom
117        <code>LoggerFactory</code>
118        class name.
119        <programlisting language="java">java -Dhazelcast.logging.class=foo.bar.MyLoggingFactory</programlisting>
120    </para>
121
122    <para>
123        You can also listen to logging events generated by Hazelcast runtime by registering <literal>LogListener</literal>s to<literal>LoggingService</literal>.
124        <programlisting language="java">
125LogListener listener = new LogListener() {
126    public void log(LogEvent logEvent) {
127        // do something
128    }
129}
130LoggingService loggingService = Hazelcast.getLoggingService();
131loggingService.addLogListener(Level.INFO, listener):
132        </programlisting>
133        Through the
134        <literal>LoggingService</literal>
135        you can get the current used ILogger implementation and log your own messages too.
136    </para>
137</sect1>