| <?xml version="1.0" encoding="utf-8"?> |
| |
| <!-- |
| |
| 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 id="Qpid-Java-Log4j"><title> |
| Configure Log4j CompositeRolling Appender |
| </title> |
| <section role="h2" id="ConfigureLog4jCompositeRollingAppender-HowtoconfiguretheCompositeRollinglog4jAppender"><title> |
| How to configure the CompositeRolling log4j Appender |
| </title> |
| <para> |
| There are several sections of our default log4j file that will |
| need your attention if you wish to fully use this Appender. |
| </para> |
| |
| <orderedlist> |
| <listitem> |
| <para>Enable the Appender</para> |
| <para> |
| The default log4j.xml file uses the FileAppender, swap this for |
| the ArchivingFileAppender as follows: |
| </para> |
| <programlisting> |
| <!-- Log all info events to file --> |
| <root> |
| <priority value="info"/> |
| |
| <appender-ref ref="ArchivingFileAppender"/> |
| </root> |
| </programlisting> |
| </listitem> |
| <listitem> |
| <para> |
| Configure the Appender |
| </para> |
| |
| <para> |
| The Appender has a number of parameters that can be adjusted |
| depending on what you are trying to achieve. For clarity lets |
| take a quick look at the complete default appender: |
| </para> |
| <programlisting> |
| <appender name="ArchivingFileAppender" class="org.apache.log4j.QpidCompositeRollingAppender"> |
| <!-- Ensure that logs allways have the dateFormat set--> |
| <param name="StaticLogFileName" value="false"/> |
| <param name="File" value="${QPID_WORK}/log/${logprefix}qpid${logsuffix}.log"/> |
| <param name="Append" value="false"/> |
| <!-- Change the direction so newer files have bigger numbers --> |
| <!-- So log.1 is written then log.2 etc This prevents a lot of file renames at log rollover --> |
| <param name="CountDirection" value="1"/> |
| <!-- Use default 10MB --> |
| <!--param name="MaxFileSize" value="100000"/--> |
| <param name="DatePattern" value="'.'yyyy-MM-dd-HH-mm"/> |
| <!-- Unlimited number of backups --> |
| <param name="MaxSizeRollBackups" value="-1"/> |
| <!-- Compress(gzip) the backup files--> |
| <param name="CompressBackupFiles" value="true"/> |
| <!-- Compress the backup files using a second thread --> |
| <param name="CompressAsync" value="true"/> |
| <!-- Start at zero numbered files--> |
| <param name="ZeroBased" value="true"/> |
| <!-- Backup Location --> |
| <param name="backupFilesToPath" value="${QPID_WORK}/backup/log"/> |
| |
| <layout class="org.apache.log4j.PatternLayout"> |
| <param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/> |
| </layout> |
| </appender> |
| </programlisting> |
| <para> |
| The appender configuration has three groups of parameter |
| configuration. |
| </para><para> |
| The first group is for configuration of the file name. The |
| default is to write a log file to QPID_WORK/log/qpid.log |
| (Remembering you can use the logprefix and logsuffix values to |
| modify the file name, see Property Config). |
| </para> |
| <programlisting> |
| <!-- Ensure that logs always have the dateFormat set--> |
| <param name="StaticLogFileName" value="false"/> |
| <param name="File" value="${QPID_WORK}/log/${logprefix}qpid${logsuffix}.log"/> |
| <param name="Append" value="false"/> |
| </programlisting> |
| <para> |
| The second section allows the specification of a Maximum File |
| Size and a DatePattern that will be used to move on to the next |
| file. |
| </para><para> |
| When MaxFileSize is reached a new log file will be created |
| The DataPattern is used to decide when to create a new log file, |
| so here a new file will be created for every minute and every |
| 10Meg of data. So if 15MB of data is made every minute then there |
| will be two log files created each minute. One at the start of |
| the minute and a second when the file hit 10MB. When the next |
| minute arrives a new file will be made even though it only has |
| 5MB of content. For a production system it would be expected to |
| be changed to something like 'yyyy-MM-dd' which would make a new |
| log file each day and keep the files to a max of 10MB. |
| </para><para> |
| The final MaxSizeRollBackups allows you to limit the amount of |
| disk you are using by only keeping the last n backups. |
| </para> |
| <programlisting> |
| <!-- Change the direction so newer files have bigger numbers --> |
| <!-- So log.1 is written then log.2 etc This prevents a lot of file renames at log rollover --> |
| <param name="CountDirection" value="1"/> |
| <!-- Use default 10MB --> |
| <!--param name="MaxFileSize" value="100000"/--> |
| <param name="DatePattern" value="'.'yyyy-MM-dd-HH-mm"/> |
| <!-- Unlimited number of backups --> |
| <param name="MaxSizeRollBackups" value="-1"/> |
| </programlisting> |
| <para> |
| The final section allows the old log files to be compressed and |
| copied to a new location. |
| </para> |
| <programlisting> |
| <!-- Compress(gzip) the backup files--> |
| <param name="CompressBackupFiles" value="true"/> |
| <!-- Compress the backup files using a second thread --> |
| <param name="CompressAsync" value="true"/> |
| <!-- Start at zero numbered files--> |
| <param name="ZeroBased" value="true"/> |
| <!-- Backup Location --> |
| <param name="backupFilesToPath" value="${QPID_WORK}/backup/log"/> |
| </programlisting> |
| </listitem> |
| </orderedlist> |
| <!--h2--></section> |
| </section> |