Configuring Logging
To enable logging, add a Logging
section to the configuration and specify a Target
with a Protocol
value, along with any other relevant options. You can configure multiple targets by including multiple Target
definitions within the Logging
tag.
For details on logging, including a cross reference to the types of messages and a breakdown of the format AMPS uses in log messages, see the other subsections of Logging.
Described below are the configuration elements that apply to all logging protocols. Expand each item for more details.
Logging to Files
Described below are the configuration items available for logging to a standard or compressed file. Expand each item for more details.
Standard File Examples
The following logging target definition would place a log file with a name constructed from the timestamp and current log rotation number in the ./logs
subdirectory. The first log would have a name similar to ./logs/20121223125959-00000.log
and would store up to 2GB before creating the next log file named ./logs/201212240232-00001.log
.
<AMPSConfig>
...
<Logging>
<Target>
<Protocol>file</Protocol>
<Level>info</Level>
<FileName>./logs/%Y%m%d%H%M%S-%n.log</FileName>
<RotationThreshold>2G</RotationThreshold>
</Target>
</Logging>
...
</AMPSConfig>
This example will create a single log named amps.log
which will be appended to during each logging event. If amps.log
contains data when AMPS starts, that data will be preserved and new log messages will be appended to the file.
<AMPSConfig>
...
<Logging>
<Target>
<Protocol>file</Protocol>
<Level>info</Level>
<FileName>amps.log</FileName>
</Target>
</Logging>
...
</AMPSConfig>
Compressed File Example
The following logging target definition would place a log file with a name constructed from the timestamp and current log rotation number in the ./logs
subdirectory. The first log would have a name similar to ./logs/20121223125959-0.log.gz
and would store up to 2GB of uncompressed log messages before creating the next log file named ./logs/201212240232-1.log.gz
.
<AMPSConfig>
...
<Logging>
<Target>
<Protocol>gzip</Protocol>
<Level>info</Level>
<FileName>./logs/%Y%m%d%H%M%S-%n.log.gz</FileName>
<RotationThreshold>2G</RotationThreshold>
</Target>
</Logging>
...
</AMPSConfig>
Logging to Syslog
Described below are the configuration items available for logging to syslog
. Expand each item for more details.
Below is an example of a syslog
logging target that logs all messages at the critical
severity level or higher, as well as log messages matching 30-0000
to the syslog
.
<AMPSConfig>
...
<Logging>
<Target>
<Protocol>syslog</Protocol>
<Level>critical</Level>
<IncludeErrors>30-0000</IncludeErrors>
<Ident>\amps dma</Ident>
<Options>LOG_CONS,LOG_NDELAY,LOG_PID</Options>
<Facility>LOG_USER</Facility>
</Target>
</Logging>
...
</AMPSConfig>
Below is an example that shows how to record messages to both syslog
and file
logging targets.
<Logging>
<!-- Record trace messages to files in /var/tmp/. -->
<Target>
<Protocol>file</Protocol>
<FileName>/var/tmp/amps/logs/%Y%m%d%H%M%S-%n.log</FileName>
<RotationThreshold>2G</RotationThreshold>
<Level>trace</Level>
<Levels>critical</Levels>
</Target>
<!-- Record critical messages to the system logger. -->
<Target>
<Protocol>syslog</Protocol>
<Level>critical</Level>
<Ident>amps_dma</Ident>
<Options>LOG_CONS,LOG_NDELAY,LOG_PID</Options>
<Facility>LOG_USER</Facility>
</Target>
<!-- Record only the AMPS initialization message. -->
<Target>
<Protocol>file</Protocol>
<FileName>/var/tmp/amps/logs/initMessage</FileName>
<IncludeErrors>00-0015</IncludeErrors>
</Target>
</Logging>
Logging to the Console
The console logging target instructs AMPS to log certain messages to the console. Both the standard output and standard error streams are supported.
Use a Protocol
setting of stdout
to select standard output, or stderr
for standard error.
Below is an example of a console logger that logs all messages at the info
or warning
level to standard out and all messages at the error
level or higher to standard error (which includes error
, critical
and emergency
levels).
<AMPSConfig>
...
<Logging>
<Target>
<Protocol>stdout</Protocol>
<Levels>info,warning</Levels>
</Target>
<Target>
<Protocol>stderr</Protocol>
<Level>error</Level>
</Target>
</Logging>
...
</AMPSConfig>
Example: Development Instance Logging
This logging configuration may be useful for development instances.
This configuration is intended to meet the following considerations:
Warning, error, and critical messages are logged to standard output to make it easy for a developer to see if a command to AMPS produces an error.
Message traffic in and out of AMPS is logged to the
trace.log
file for debugging purposes. This file is rotated every 250MB. When the file hits the 250MB limit, it will be cleared and overwritten with new entries.Static information about the instance -- including the configuration, detected hardware configuration, and so forth -- is logged to the
instance-info.log
. Logging this information to a separate file means it will still be available when the trace log is replaced.
<AMPSConfig>
...
<Logging>
<Target>
<Protocol>file</Protocol>
<Level>trace</Level>
<FileName>./logs/trace.log</FileName>
<RotationThreshold>250MB</RotationThreshold>
</Target>
<Target>
<Protocol>stdout</Protocol>
<Level>warning</Level>
<IncludeErrors>00-0015</IncludeErrors>
</Target>
<Target>
<Protocol>file</Protocol>
<FileName>./logs/instance-info.log</FileName>
<IncludeErrors>00-0001,00-0002,00-0004,00-0015,
00-0030,00-0033,00-0032,00-0054,
01-0019,2D-0005,2D-0006,2D-0008,2D-0011</IncludeErrors>
</Target>
</Logging>
...
</AMPSConfig>
Last updated