| <?xml version="1.0"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you 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. |
| |
| --> |
| |
| <section xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="Java-Broker-Runtime-Logging"> |
| <title>Logging</title> |
| <para>This section describes the flexible logging capabilities of the Apache Qpid Broker-J.</para> |
| <para> |
| <itemizedlist> |
| <listitem> |
| <para>The Broker is capable of sending logging events to a variety of destinations including |
| plain files, remote syslog daemons, and an in-memory buffer (viewable from Management). |
| The system is also open for extension meaning it is possible to produce a plugin to log to |
| a bespoke destination.</para> |
| </listitem> |
| <listitem> |
| <para>Logging can be dynamically configured at runtime. For instance, it is possible to |
| temporarily increase the logging verbosity of the system whilst a problem is investigated |
| and then revert later, all without the need to restart the Broker.</para> |
| </listitem> |
| <listitem> |
| <para>Virtualhosts can be configured to generate their own separate log, and the Broker is |
| capable of generating a log either inclusive or exclusive of virtualhost events.</para> |
| </listitem> |
| <listitem> |
| <para>Logs are accessible over Management, removing the need for those operating the Broker |
| to have shell level access.</para> |
| </listitem> |
| </itemizedlist> |
| </para> |
| <para>In the remainder of this section you will first find a description of the concepts used in |
| the logging subsystem. Next, you find a description of the default configuration. The section |
| then concludes with a in-depth description of the loggers themselves and how they may be |
| configured.</para> |
| <section xml:id="Java-Broker-Runtime-Logging-Concepts"> |
| <title>Concepts</title> |
| |
| <para>The logging subsystem uses two concepts:</para> |
| <para> |
| <itemizedlist> |
| <listitem> |
| <para>A <emphasis>Logger</emphasis> is responsible for production of a log. The Broker |
| ships a variety of loggers, for instance, a file logger, which is capable of writing a |
| log file to the file system, a Syslog Logger capable of writing to a remote syslog |
| daemon and console logger capable of writing to stdout or stderr.</para> |
| <para>Loggers are attached at two points within the Broker Model; the Broker itself and |
| the virtualhosts. Loggers attached at the Broker can capture log events for the system |
| as a whole, or can exclude events related to virtualhosts.</para> |
| <para>Loggers attached to a virtualhost capture log events relating to that virtualhost |
| only.</para> |
| <para>The Broker and virtualhosts can have zero or more Loggers. If no loggers are |
| configured, no logging is generated at all.</para> |
| </listitem> |
| <listitem> |
| <para><emphasis>Inclusion rules</emphasis> govern what appears within a log. Inclusion |
| rules are associated with Loggers. This means it is possible for different Loggers to |
| have different contents.</para> |
| <para>A Logger with no inclusion rules will produce an empty log.</para> |
| </listitem> |
| </itemizedlist> |
| </para> |
| </section> |
| <section xml:id="Java-Broker-Runtime-Logging-Default-Configuration"> |
| <title>Default Configuration</title> |
| <para>The default configuration is designed to be suitable for use without change in small |
| production environments. It has the following characteristics:</para> |
| <para> |
| <itemizedlist> |
| <listitem> |
| <para>The Broker generates a single log file <literal>qpid.log</literal>. This logfile is |
| rolled automatically when the file reaches 100MB. A maximum history of one file is |
| retained. On restart the the log will be appended to.</para> |
| <para>The log contains: <itemizedlist> |
| <listitem><para>All operational logging events. See <xref linkend="Java-Broker-Appendix-Operation-Logging"/>.</para></listitem> |
| <listitem><para>Log events from Qpid itself deemed informational or |
| higher.</para></listitem> |
| <listitem><para>Log events from Qpid's dependencies (such as Derby or Jetty) that are |
| deemed warning or higher.</para></listitem> |
| </itemizedlist> |
| </para> |
| <para>The default location for the log file is |
| <literal>\${QPID_WORK}/log/qpid.log</literal>.</para> |
| </listitem> |
| <listitem> |
| <para>The Broker also caches the last 4096 log events in a memory cache. By default, the |
| memory logger logs the same things the file logger does.</para> |
| </listitem> |
| </itemizedlist> |
| </para> |
| <para>The configuration can be customised at runtime using Management. This makes it possible to |
| investigate unusual conditions <emphasis>without</emphasis> the need to restart the Broker. |
| For instance, you may alter the logging level so that a verbose log is produced whilst an |
| investigation is in progress and revert the setting later, all without the need to restart the |
| Broker.</para> |
| </section> |
| <section xml:id="Java-Broker-Runtime-Logging-Loggers"> |
| <title>Loggers</title> |
| <para>Loggers are responsible for the writing of a log. The log includes log events that match a |
| Logger's inclusion rules.</para> |
| <para>Loggers are associated with either the Broker or a virtualhost. Virtualhost loggers write |
| only log events related to that virtualhost. Broker Loggers write log events from the Broker |
| as a whole. Optionally a Broker Logger can be configured to exclude log events coming from |
| virtualhosts. These abilities can be usefully exploited together in managed service scenarios |
| to produce separate logs for separate user groups.</para> |
| <para>Loggers can be added or removed at runtime, without restarting the Broker. However changes |
| to a Logger's configuration such as filenames and rolling options don't take effect until the |
| next restart. Changes to a Logger's inclusion rules take effect immediately.</para> |
| <para>All loggers allow the log event layout to be customised. Loggers understand <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://logback.qos.ch/manual/layouts.html#ClassicPatternLayout"> Logback Classic |
| Pattern Layouts</link>. </para> |
| <para>The following sections describes each Logger implementation in detail.</para> |
| <section xml:id="Java-Broker-Runtime-Logging-Loggers-FileLogger"> |
| <title>FileLogger</title> |
| <para>A <emphasis>FileLogger</emphasis> - writes a log file to the filesystem. The name and |
| location of the log file, the rolling configuration, and compression options can be |
| configured.</para> |
| <para>The <emphasis>roll daily</emphasis> option, if enabled, will cause the log file will be |
| rolled at midnight local time. The rolled over file will have a suffix in the form |
| <literal>yyyy-mm-dd</literal>. In roll daily mode, <emphasis>maximum number of rolled |
| files</emphasis> controls the maximum number of <emphasis>days</emphasis> to be retained. |
| Older files will be deleted.</para> |
| <para>The <emphasis>maximum file size</emphasis> option limits the size of any one log file. |
| Once a log file reaches the given size, it will be rolled. The rolled over file will have |
| the numeric suffix, beginning at <literal>1</literal>. If the log file rolls again, first |
| the existing file with the suffix <literal>.1</literal> is renamed to <literal>.2</literal> |
| and so forth. If roll daily is not in use, <emphasis>maximum number of rolled |
| files</emphasis> governs the number of rolled <emphasis>files</emphasis> that will be |
| retained.</para> |
| <para><emphasis>Roll on restart</emphasis> governs whether the log file is rolled when the |
| Broker is restarted. If not ticked, the Broker will append to the existing log file until it |
| needs to be rolled.</para> |
| </section> |
| <section xml:id="Java-Broker-Runtime-Logging-Loggers-ConsoleLogger"> |
| <title>ConsoleLogger</title> |
| <para><emphasis>ConsoleLogger</emphasis> - writes a log file standard out or standard |
| error.</para> |
| </section> |
| <section xml:id="Java-Broker-Runtime-Logging-Loggers-SyslogLogger"> |
| <title>SyslogLogger</title> |
| <para><emphasis>SyslogLogger</emphasis> - writes a log file to a syslog daemon using the |
| <literal>USER</literal> facility. The hostname and port number of the syslog daemon can be |
| configured.</para> |
| <para>Log entries can be prefixed with a string. This string defaults to include the word |
| <literal>Qpid</literal> and the name of the Broker or virtualhost. This serves to |
| distinguish the logging generated by this Qpid instance, from other Qpid instances, or other |
| applications using the <literal>USER</literal>.</para> |
| </section> |
| <section xml:id="Java-Broker-Runtime-Logging-Loggers-MemoryLogger"> |
| <title>MemoryLogger</title> |
| <para><emphasis>MemoryLogger</emphasis> - writes a log file to a circular in-memory buffer. By |
| default the circular buffer holds the last 4096 log events. The contents of the buffer can |
| be viewed via Management. See <xref linkend="Java-Broker-Runtime-Logging-Management-MemoryLogger"/></para> |
| </section> |
| <section xml:id="Java-Broker-Runtime-Logging-Loggers-GraylogLogger"> |
| <title>GraylogLogger</title> |
| <para><emphasis>GraylogLogger</emphasis> - sends log messages to a Graylog server in |
| <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://docs.graylog.org/en/3.2/pages/gelf.html">GELF format</link> via TCP. |
| The hostname and port number of the Graylog server has to be configured. The content of the log messages is also configurable.</para> |
| <para>The Broker has to be built using option <code>-Dgraylog</code> to support Graylog logger, please visit |
| <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://github.com/apache/qpid-broker-j/blob/master/doc/developer-guide/src/main/markdown/build-instructions.md#maven-commands">build instructions</link>. |
| </para> |
| </section> |
| </section> |
| <section xml:id="Java-Broker-Runtime-Logging-InclusionRules"> |
| <title>Inclusion Rules</title> |
| <para>A <emphasis>Logger</emphasis> has one or more <emphasis>inclusion rules</emphasis>. These |
| govern what appears in the log. A Logger with no inclusion rules will log nothing.</para> |
| <para>Inclusion rules can be added, removed or changed at runtime. Changes take place |
| immediately.</para> |
| <para> |
| <itemizedlist> |
| <listitem> |
| <para>The <emphasis>Name And Level</emphasis> inclusion rule accepts log events that match |
| a given <emphasis>log event source name</emphasis> and have a level that equals or |
| exceeds the specified value.</para> |
| <para>The log event source name refers to the fully qualified class name from which the |
| event originates. These names permit a trailing wild card <literal>.*</literal>. For |
| instance a source name of <literal>org.apache.qpid.*</literal> will match all events |
| from classes in the package <literal>org.apache.qpid</literal> and any sub packages |
| beneath.</para> |
| <para>The <emphasis>Level</emphasis> governs the level of the events that will be included |
| in the log. It may take one of the following values: ERROR, WARN, INFO, DEBUG, TRACE |
| where ERROR is considered the highest and TRACE the lowest. In addition, there are two |
| special values: OFF and ALL, the former excludes all log events whereas the latter will |
| include everything. When considering whether a logging event should be included in the |
| log, the logging event must have a level that matches that of the inclusion rule or be |
| higher, otherwise the log event will not appear in the log.</para> |
| </listitem> |
| </itemizedlist> |
| </para> |
| </section> |
| <section xml:id="Java-Broker-Runtime-Logging-Management"> |
| <title>Logging Management</title> |
| <para>The logging subsystem can be completely managed from the Web Management Console or the |
| REST API. You can: <itemizedlist> |
| <listitem><para>Add, remove, or change the configuration of Loggers.</para></listitem> |
| <listitem><para>Add, remove, or change the Inclusion Rules.</para></listitem> |
| <listitem><para>For FileLoggers, download the log file and rolled log files associated with |
| the Logger.</para></listitem> |
| <listitem><para>For MemoryLoggers, view the last <literal>n</literal> log |
| events</para></listitem> |
| </itemizedlist> |
| </para> |
| <para> The figure that follows shows a FileLogger. The attributes area shows the configuration |
| of the Logger. The inclusion rule table shows the rules that are associated with the Logger. |
| The area towards the bottom of the tab allows the log files to be downloaded to the browser. |
| <figure xml:id="Java-Broker-Runtime-Logging-Management-FileLogger"> |
| <title>Viewing a file logger</title> |
| <mediaobject> |
| <imageobject> |
| <imagedata fileref="images/Management-Web-Logging-FileLogger.png" format="PNG" scalefit="1" width="900px"/> |
| </imageobject> |
| <textobject> |
| <phrase>Viewing a file logger</phrase> |
| </textobject> |
| </mediaobject> |
| </figure> |
| </para> |
| <para> The figure below shows the editing of the level of an inclusion rule. <figure xml:id="Java-Broker-Runtime-Logging-Management-InclusionRule"> |
| <title>Editing an inclusion rule</title> |
| <mediaobject> |
| <imageobject> |
| <imagedata fileref="images/Management-Web-Logging-InclusionRule.png" format="PNG" scalefit="1" width="900px"/> |
| </imageobject> |
| <textobject> |
| <phrase>Editing an inclusion rule</phrase> |
| </textobject> |
| </mediaobject> |
| </figure> |
| </para> |
| <para> The figure below shows a Memory Logger. Note that the Memory Logger provides access to |
| the cached message via the viewer towards the bottom on the tab. <figure xml:id="Java-Broker-Runtime-Logging-Management-MemoryLogger"> |
| <title>Viewing a memory logger</title> |
| <mediaobject> |
| <imageobject> |
| <imagedata fileref="images/Management-Web-Logging-MemoryLogger.png" format="PNG" scalefit="1" width="900px"/> |
| </imageobject> |
| <textobject> |
| <phrase>Viewing a memory logger</phrase> |
| </textobject> |
| </mediaobject> |
| </figure> |
| </para> |
| </section> |
| </section> |