How to redirect logs to reduce verbosity
Platform Notice: Data Center Only - This article only applies to Atlassian apps on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Managing system log files for Bamboo. This can include cases where:
Log files are duplicated
Log files are too large (or verbose)
Log files contain unnecessary information
If, for example, we have a Bamboo instance configured to write logs to /var/log/bamboo.log, but the same log lines are being seen in /var/log/messages, we may want to disable the logging to /var/log/messages.
This can be related to:
Local or remote agent application-side logging changes, including bundled
log4jsettingsLocal or remote agent system-side logging changes
By default, many systems are configured to log to /var/log/system or /var/log/messages depending on the source of the logs.
Solution
Solutions
Here are three possible options available to you.
A. log4j/log4j2
For Bamboo versions prior 9
Ensure that BAMBOO_INSTALL/atlassian-bamboo/WEB-INF/classes/log4j.properties is sending logs to the desired locations. In the log4j.properties example below, INFO level logs are being sent to BAMBOO_HOME/logs/atlassian-bamboo.log.
default log4j.properties excerpt
log4j.rootLogger=INFO, console, filelog
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %p [%t] [%c{1}] %m%n
#using 'bamboo home aware' appender. If the File is relative a relative Path the file goes into {bamboo.home}/logs
log4j.appender.filelog=com.atlassian.bamboo.log.BambooRollingFileAppender
log4j.appender.filelog.File=atlassian-bamboo.log
log4j.appender.filelog.MaxFileSize=20480KB
log4j.appender.filelog.MaxBackupIndex=5
log4j.appender.filelog.layout=org.apache.log4j.PatternLayout
log4j.appender.filelog.layout.ConversionPattern=%d %p [%t] [%c{1}] %m%nFor Bamboo version 9 and above
Ensure that BAMBOO_INSTALL/atlassian-bamboo/WEB-INF/classes/log4j2.properties is sending logs to the desired locations. In the log4j2.properties example below, INFO level logs are being sent to BAMBOO_HOME/logs/atlassian-bamboo.log.
default log4j2.properties excerpt
packages = com.atlassian.bamboo.log
status = warn
rootLogger = INFO, console, filelog
appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{DEFAULT} %p [%t] [%C{1}] %m%n
appender.console.filter.threshold.type = ThresholdFilter
appender.console.filter.threshold.level = OFF
#using 'bamboo home aware' appender. If the File is relative a relative Path the file goes into {bamboo.home}/logs
appender.filelog.type = BambooRollingFile
appender.filelog.name = filelog
appender.filelog.fileName = atlassian-bamboo.log
appender.filelog.filePattern = atlassian-bamboo.log.%i
appender.filelog.layout.type = PatternLayout
appender.filelog.layout.pattern = %d{DEFAULT} %p [%t] [%C{1}] %m%n
appender.filelog.policies.type = Policies
appender.filelog.policies.size.type = SizeBasedTriggeringPolicy
appender.filelog.policies.size.size = 100MB
appender.filelog.strategy.type = DefaultRolloverStrategy
appender.filelog.strategy.max = 5
appender.filelog.strategy.fileIndex = minℹ️ More information on logging with log4j in Bamboo, please refer to the guide on Logging in Bamboo.
B. syslog/d
syslog is a system log server included in many Unix distributions (including Mac OS X). syslogd is syslog run as a daemon or background process.
Using configuration files, syslog will route logs to different locations based on:
Type
Source
Level
For example, if Bamboo logs are coming from internal source local0, and we don't want any Bamboo logs in /var/log/messages, add the following lines to syslogd.conf:
syslog.conf example
# format: source.level<TAB>target
local0.none /var/log/messagesDocumentation for syslog can be found online at http://linux.die.net/man/5/syslog.conf, or by running man syslog in your Terminal or Command Line.
C. rsyslog/d
rsyslog is similar to syslog, but with more functionality and configurable options. As with syslogd, rsyslogd is rsyslog run as a daemon or background process.
For example, once rsyslogd is running, Bamboo logs can be redirected to /var/log/bamboo.log, and not log to system logs. To achieve this, first find the programname attribute and update rsyslog.conf as outlined below.
To find the programname attribute, look in the system log, for example
/var/log/messagesor/var/log/syslog, for the Bamboo entries. The lines are formatted as follows:Aug 9 23:39:31 my.server.hostname myprogram[pid]: log entryUsing the
programnamefrom the log, add the following lines to yourrsyslog.conf:rsyslog.conf
if $programname startswith 'myprogram' then /var/log/bamboo.log & stopThe second line excludes everything else that matches the same
ifcondition.
Documentation for rsyslog can be found online at http://www.rsyslog.com/doc/v8-stable/ or by running man rsyslog on your Terminal or Command Line after rsyslog is installed.
Notes
Your operating system may already have one of these utilities installed
In addition to
syslog, Mac OS X also has the Apple System Log (asl)
Was this helpful?