Community Articles
Find and share helpful community-sourced technical articles
Labels (1)

Steps to configure ambari-server to archive log files.

1. Open /etc/ambari-server/conf/log4j.properties file,

log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=${ambari.log.dir}/${ambari.log.file}
log4j.appender.file.MaxFileSize=80MB
log4j.appender.file.MaxBackupIndex=60
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{DATE} %5p [%t] %c{1}:%L - %m%n

to

log4j.appender.file=org.apache.log4j.rolling.RollingFileAppender
log4j.appender.file.rollingPolicy=org.apache.log4j.rolling.FixedWindowRollingPolicy  
log4j.appender.file.triggeringPolicy=org.apache.log4j.rolling.SizeBasedTriggeringPolicy  
log4j.appender.file.File=${ambari.log.dir}/${ambari.log.file}
log4j.appender.file.triggeringPolicy.MaxFileSize=10485760
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{DATE} %5p [%t] %c{1}:%L - %m%n
log4j.appender.file.rollingPolicy.FileNamePattern=${ambari.log.dir}/${ambari.log.file}.%i.log.gz

Note: change the configurations appropriately as per your needs.

2. download apache-log4j-extras.jar from : https://logging.apache.org/log4j/extras/download.html

3. copy downloaded jar to /usr/lib/ambari-server/ path

4. Restart ambari-server

Check the logs files getting archived. look out for warnings in ambari-server.out.

I have used https://community.hortonworks.com/articles/50058/using-log4j-extras-how-to-rotate-as-well-as-zip-th.... as reference.

1,342 Views