ansible-middleware / amq

A collection to manage AMQ brokers
Apache License 2.0
20 stars 11 forks source link

How to clean up old log files automatically? #201

Closed michie1 closed 2 days ago

michie1 commented 4 days ago
SUMMARY

In log4j2.properties is see max is set to 5, but when I run ls log, I see many more files. How to clean up old log files automatically? Same holds for audit logs.

ISSUE TYPE
ANSIBLE VERSION

Ansible 11

COLLECTION VERSION

2.2.5

STEPS TO REPRODUCE

Login the broker, wait 10 days.

EXPECTED RESULTS

I would expect to see the log files of the last 5 days.

ACTUAL RESULTS

I see all log files of the last 10 days.

RanabirChakraborty commented 3 days ago

@michie1 Can you please explain the issue a bit more in detail and probably add the playbook you are using?

michie1 commented 3 days ago

I'm using the redhat.amq_broker.amq_broker role. I can't share you all the vars we set. Do you have some specific vars in mind you need to know?

Here's log4j2.properties which is generated by the role.

# Ansible managed
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Log4J 2 configuration

# Monitor config file every X seconds for updates
monitorInterval = 5

rootLogger = INFO, console, log_file

logger.amq_broker.name=org.apache.amq_broker
logger.amq_broker.level=INFO

logger.artemis_server.name=org.apache.activemq.artemis.core.server
logger.artemis_server.level=INFO

logger.artemis_journal.name=org.apache.activemq.artemis.journal
logger.artemis_journal.level=INFO

logger.artemis_utils.name=org.apache.activemq.artemis.utils
logger.artemis_utils.level=INFO

# CriticalAnalyzer: If you have issues with the CriticalAnalyzer, setting this to TRACE would give
# you extra troubleshooting info, but do not use TRACE regularly as it would incur extra CPU usage.
logger.critical_analyzer.name=org.apache.activemq.artemis.utils.critical
logger.critical_analyzer.level=INFO

logger.artemis_jms.name=org.apache.activemq.artemis.jms
logger.artemis_jms.level=INFO

logger.artemis_integration_bootstrap.name=org.apache.activemq.artemis.integration.bootstrap
logger.artemis_integration_bootstrap.level=INFO

# Audit loggers: to enable change levels from OFF to INFO
logger.audit_base = INFO, audit_log_file
logger.audit_base.name = org.apache.activemq.audit.base
logger.audit_base.additivity = false

logger.audit_resource = INFO, audit_log_file
logger.audit_resource.name = org.apache.activemq.audit.resource
logger.audit_resource.additivity = false

logger.audit_message = INFO, audit_log_file
logger.audit_message.name = org.apache.activemq.audit.message
logger.audit_message.additivity = false

# Jetty logger levels
logger.jetty.name=org.eclipse.jetty
logger.jetty.level=WARN

# Quorum related logger levels
logger.curator.name=org.apache.curator
logger.curator.level=WARN
logger.zookeeper.name=org.apache.zookeeper
logger.zookeeper.level=ERROR

# Console appender
appender.console.type=Console
appender.console.name=console
appender.console.layout.type=PatternLayout
appender.console.layout.pattern=%d %-5level [%logger] %msg%n

# Log file appender
appender.log_file.type = RollingFile
appender.log_file.name = log_file
appender.log_file.fileName = ${sys:artemis.instance}/log/artemis.log
appender.log_file.filePattern = ${sys:artemis.instance}/log/artemis.log.%d{yyyy-MM-dd}
appender.log_file.layout.type = PatternLayout
appender.log_file.layout.pattern = %d %-5level [%logger] %msg%n
appender.log_file.policies.type = Policies
appender.log_file.policies.cron.type = CronTriggeringPolicy
appender.log_file.policies.cron.schedule = 0 0 0 * * ?
appender.log_file.policies.cron.evaluateOnStartup = true
appender.log_file.strategy.type=DefaultRolloverStrategy
appender.log_file.strategy.max=5

# Audit log file appender
appender.audit_log_file.type = RollingFile
appender.audit_log_file.name = audit_log_file
appender.audit_log_file.fileName = ${sys:artemis.instance}/log/audit.log
appender.audit_log_file.filePattern = ${sys:artemis.instance}/log/audit.log.%d{yyyy-MM-dd}
appender.audit_log_file.layout.type = PatternLayout
appender.audit_log_file.layout.pattern = %d [AUDIT](%t) %msg%n
appender.audit_log_file.policies.type = Policies
appender.audit_log_file.policies.cron.type = CronTriggeringPolicy
appender.audit_log_file.policies.cron.schedule = 0 0 0 * * ?
appender.audit_log_file.policies.cron.evaluateOnStartup = true
appender.audit_log_file.strategy.type=DefaultRolloverStrategy
appender.audit_log_file.strategy.max=5
guidograzioli commented 2 days ago

Hello, thanks for reporting. It is a bug in the template, the filePattern is missing %i so the DefaultRolloverStrategy cannot find file to roll.