search cancel

Clearing old logs from WebViewer 14.0 filesystem

book

Article ID: 214704

calendar_today

Updated On:

Products

Output Management Web Viewer

Issue/Introduction

Since installing Webviewer, our ZFS files are getting larger and larger, and it seems to be that log files are not being deleted in the .$CAWVHOME/logs/   directory. This is taking unnecessary disk space. Is there some option to only retain for a set period or some housekeeping that has been over looked?

 

Environment

Release : 14.0

Component : CA Output Management Web Viewer

DVWEB

Resolution

Note that log4j2 does have a method for deleting old log files via the DefaultRolloverStrategy – but it is not in the sample log4j2.xml file that is distributed. 

Make a backup of your log4j2.xml file before making any changes 

Here is a sample DefaultRolloverStrategy that deletes log files after 50 days: -
 

<DefaultRolloverStrategy max="14">                   

    <Delete basePath="${logPath}/" maxDepth="1">     

         <IfFileName glob="*.log" />                 

         <IfLastModified age="50d" />                

    </Delete>                                         

</DefaultRolloverStrategy>

 

The 50 days comes from age=”50d” which can be changed.

Note that this only gets triggered when the day rolls over, if you want it triggered at startup time as well, add OnStartupTriggeringPolicy as a Policy.  For example:-

<Policies>                                           

    <OnStartupTriggeringPolicy/>                    

    <TimeBasedTriggeringPolicy/>                      

    <!-- <SizeBasedTriggeringPolicy size="1 KB" /> -->

</Policies>

Additional Information

IMPORTANT: Log4j only does the clean-up when the policy is triggered.  According to the log4j documentation, <TimeBasedTriggeringPolicy/> means the policy will be triggered once the date/time pattern no longer applies to the active file.  Since Web Viewer only calls log4j when a log message is issued that means the date has to change and a log message has to be written – if there is no activity in Web Viewer and no log records are being written then the policy will not be triggered.

 To force the policy to be triggered at start-up (ie when the first log record is written) you will need to add <OnStartupTriggeringPolicy /> in <Policies>.

see the official Apache Log4j Documentation.