WSO2 MI 4.2.0 Issues in log4j action delete

56 Views Asked by At

WSO2 MI 4.2.0

I am using Wso2 micro integrator version 4.2.0. and a rollover policy based on a time period for the log files. I'm trying to delete old rollover files with more than 58 days, meaning that I want to keep ~58 days of logs with the following configuration (as recommended on https://apim.docs.wso2.com/en/latest/administer/logging-and-monitoring/logging/managing-log-growth/):

appender.CARBON_LOGFILE.strategy.action.type = Delete
appender.CARBON_LOGFILE.strategy.action.basepath = ${sys:carbon.home}/repository/logs/
appender.CARBON_LOGFILE.strategy.action.maxdepth = 1
appender.CARBON_LOGFILE.strategy.action.condition.type = IfLastModified
appender.CARBON_LOGFILE.strategy.action.condition.age = 58D
appender.CARBON_LOGFILE.strategy.action.PathConditions.type = IfFileName
appender.CARBON_LOGFILE.strategy.action.PathConditions.glob = wso2carbon-

Here is an image of all the configurations I have in log4j.properties for the carbon_logfile: log4j config

But the configuration seems not to be having any effect on wso2carbon log rotation or restart of the service. The service has 60 files with the pattern wso2carbon-* increasing daily. Files

Those anyone come across any similar issues? Is there something wrong in the configuration for the delete action to be applied?

1

There are 1 best solutions below

1
ycr On BEST ANSWER

The following configuration works for me. Adjust to cater to your exact requirement.

# CARBON_LOGFILE is set to be a DailyRollingFileAppender using a PatternLayout.
appender.CARBON_LOGFILE.type = RollingFile
appender.CARBON_LOGFILE.name = CARBON_LOGFILE
appender.CARBON_LOGFILE.fileName = ${sys:carbon.home}/repository/logs/wso2carbon.log
appender.CARBON_LOGFILE.filePattern = ${sys:carbon.home}/repository/logs/wso2carbon-%d{MM-dd-yyyy}.log
appender.CARBON_LOGFILE.layout.type = PatternLayout
appender.CARBON_LOGFILE.layout.pattern = [%d] %5p {%c} - %m%ex%n
appender.CARBON_LOGFILE.policies.type = Policies
appender.CARBON_LOGFILE.policies.time.type = TimeBasedTriggeringPolicy
appender.CARBON_LOGFILE.policies.time.interval = 1
appender.CARBON_LOGFILE.policies.time.modulate = true
appender.CARBON_LOGFILE.policies.size.type = SizeBasedTriggeringPolicy
appender.CARBON_LOGFILE.policies.size.size=10MB
appender.CARBON_LOGFILE.strategy.type = DefaultRolloverStrategy
appender.CARBON_LOGFILE.strategy.max = 20
appender.CARBON_LOGFILE.filter.threshold.type = ThresholdFilter
appender.CARBON_LOGFILE.filter.threshold.level = DEBUG
appender.CARBON_LOGFILE.strategy.action.type = Delete
appender.CARBON_LOGFILE.strategy.action.basePath = ${sys:carbon.home}/repository/logs
appender.CARBON_LOGFILE.strategy.action.maxDepth = 1
appender.CARBON_LOGFILE.strategy.action.IfFileName.type = IfFileName
appender.CARBON_LOGFILE.strategy.action.IfFileName.glob = wso2carbon-*.log
appender.CARBON_LOGFILE.strategy.action.IfFileName.IfLastModified.type = IfLastModified
appender.CARBON_LOGFILE.strategy.action.IfFileName.IfLastModified.age = 58d