Managing file spaces in USS logs
In the cralog4j2.xml log file, which is located in the USS installation directory, you can set a rollover policy to manage functions such as lifecycle, size and deletion for the log files.
Example of a size based rollover policy
Based on the following example of size based rollover policy, every time a file reaches a size of 5 MB, a new file is created up to a maximum of 20 new files. When the 20th file is full, the oldest file is deleted and a new file is created. The maximum logging size is 100 MB.
name="CRArollingFile"
fileName="${LOG_FILE}/bmc-common-rest-api.log"
filePattern="${LOG_FILE}/bmc-common-rest-api.%i.log"
ignoreExceptions="false">
<PatternLayout>
<Pattern>${LOG_PATTERN}</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="5MB" />
</Policies>
<DefaultRolloverStrategy max="20" />
</RollingFile>
Output
Example of a time based rollover policy
In this example, the maximum number of opsa-audit files is 10, and each day a new file is created regardless of its size:
filePattern="${LOGS_DIR}/opsa-audit%d{yyyy-MM-dd}.log"
ignoreExceptions="false">
<PatternLayout>
<Pattern>%msg%n</Pattern>
</PatternLayout>
<Policies>
<OnStartupTriggeringPolicy minSize="0"/>
<TimeBasedTriggeringPolicy interval="1"/>
</Policies>
<DirectWriteRolloverStrategy>
<Delete basePath="${LOGS_DIR}" maxDepth="1">
<IfFileName glob="opsa-audit"/>
<IfAccumulatedFileCount exceeds="10"/>
</Delete>
</DirectWriteRolloverStrategy>
</RollingFile>
Output
opsa-audit.2022.log File rwxr-xr-x fff--- -s ---- JKS SSHDG 1 218562
opsa-audit.2022.log File rwxr-xr-x fff--- -s ---- JKS SSHDG 1 186620
opsa-audit.2022.log File rwxr-xr-x fff--- -s ---- JKS SSHDG 1 126309
opsa-audit.2022.log File rwxr-xr-x fff--- -s ---- JKS SSHDG 1 26087
opsa-audit.2022.log File rwxr-xr-x fff--- -s ---- JKS SSHDG 1 0
opsa-audit.2022.log File rwxr-xr-x fff--- -s ---- JKS SSHDG 1 5889
opsa-audit.2022.log File rwxr-xr-x fff--- -s ---- JKS SSHDG 1 6041
opsa-audit.2022.log File rwxr-xr-x fff--- -s ---- JKS SSHDG 1 6661
opsa-audit.2023.log File rw-r-r- fff--- -s ---- JKS SSHDG 1 16288