How to change the log rollover criteria to capture the log on yearly, monthly, daily and hourly basis in TIBCO Data Virtualization by making changes to the log4j2.properties file?

How to change the log rollover criteria to capture the log on yearly, monthly, daily and hourly basis in TIBCO Data Virtualization by making changes to the log4j2.properties file?

book

Article ID: KB0070455

calendar_today

Updated On:

Products Versions
TIBCO Data Virtualization 8.5.x and above

Description

This article provides details on how to change the log rollover criteria to capture the logs on a yearly, monthly, daily, and hourly basis in TIBCO Data Virtualization by making changes to the log4j2.properties file

Issue/Introduction

This article provides details on how to change the log rollover criteria to capture the logs on yearly, monthly, daily and hourly basis in TIBCO Data Virtualization by making changes to the log4j2.properties file

Environment

All Supported Environments

Resolution

Users can set the log rollover criteria for each year, month, day, hour, and minute depending on their requirements.

To achieve this, the user can use the TimeBasedTriggerringPolicy.

For example:
The user wants to maintain cs_server.logs for each day on an hourly and minute basis. To achieve this, replace the already existing file pattern of the log file for which you want to make these changes with the below pattern:

===========================
appender.MAIN.filePattern={TDV_INSTALL_DIR}/logs/$${date:yyyy-MM-dd-HH}/cs_server_%d{yyyy-MM-dd-HH-mm}_%i.log

appender.MAIN.policies.time.type = TimeBasedTriggeringPolicy
appender.MAIN.policies.time.interval = 1
appender.MAIN.policies.time.modulate = true
===========================

After adding the above lines, save the changes and restart the TDV Server.

- This will add a folder with a "yyyy-MM-dd-HH" timestamp i.e. for each hour and inside this folder, you will have a cs_server_yyyy-MM-dd-HH-mm_%i log file i.e., a cs_server.log file for every minute.

- If the user wants to have a log for each month in one folder and each day inside each month's folder, they will have to change the file pattern accordingly.

Example: filePattern=logs/$${date:yyyy-MM}/cs_server_%d{yyyy-MM-dd}_%i.log

- Similarly, for a yearly basis, use the following file pattern.
Example: filePattern=logs/$${date:yyyy}/$${date:yyyy-MM}/cs_server_%d{yyyy-MM-dd}_%i.log

Note: The changes will reflect when the log file gets rolled over.

Additional Information

For more information, refer to the online article and log4j-related documentation :
#1  https://stackoverflow.com/questions/19304165/time-based-triggering-policy-in-log4j2
#2. https://logging.apache.org/log4j/2.x/manual/configuration.html#Properties