Skip to content

Commit 85c5084

Browse files
authored
Document on how to manage log files (#450)
* Document on how to manage log files * Add sample diff on how to move to size based trigger policy
1 parent 4c789e1 commit 85c5084

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

source/adminguide/management.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,52 @@ rules.
517517
the global configuration.
518518

519519

520+
Managing log files
521+
------------------
522+
523+
The log files are located in `/var/log/cloudstack`. This directory has the
524+
following subdirectories:
525+
526+
- `management` for the Management Server
527+
- `usage` for the Usage Server
528+
- `agent` for the Agent for KVM hosts
529+
530+
CloudStack uses log4j2 to manage log files. The log4j2 configuration file
531+
is located in the corresponding subdirectories in the `/etc/cloudstack/`
532+
directory and is named `log4j-cloud.xml`.
533+
534+
By default, cloudstack uses `TimeBasedTriggeringPolicy` which rolls over
535+
the log file every day and are kept indefinitely. The log files are
536+
compressed and archived in the same directory.
537+
538+
Over time, the logs can fill up the entire disk space. To avoid this, you can
539+
update the log4j-cloud.xml file to change the log file rollover and retention
540+
policy. You can change the rollover policy to `SizeBasedTriggeringPolicy`
541+
and set the maximum size of the log file. You can also set the maximum number
542+
of archived log files to keep.
543+
544+
For example, to change the rollover policy for `management-server.log` to
545+
`SizeBasedTriggeringPolicy` and set the maximum size of the log file to
546+
100MB and keep the maximum of 15 archived log files, you can update the
547+
`log4j-cloud.xml` file as follows:
548+
549+
.. code-block:: diff
550+
551+
- <RollingFile name="FILE" append="true" fileName="/var/log/cloudstack/management/management-server.log" filePattern="/var/log/cloudstack/management/management-server.log.%d{yyyy-MM-dd}.gz">
552+
+ <RollingFile name="FILE" append="true" fileName="/var/log/cloudstack/management/management-server.log" filePattern="/var/log/cloudstack/management/management-server.log.%i.gz">
553+
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
554+
+ <DefaultRolloverStrategy max="15"/>
555+
<Policies>
556+
- <TimeBasedTriggeringPolicy/>
557+
+ <SizeBasedTriggeringPolicy size="100MB"/>
558+
</Policies>
559+
<PatternLayout pattern="%d{DEFAULT} %-5p [%c{1.}] (%t:%x) %m%ex%n"/>
560+
</RollingFile>
561+
562+
563+
You can also checkout some configuration recipes from the log4j2 documentation
564+
`here <https://logging.apache.org/log4j/2.x/manual/appenders/rolling-file.html#recipes>`_.
565+
520566
Stopping and Restarting the Management Server
521567
---------------------------------------------------
522568

0 commit comments

Comments
 (0)