How to redirect logs to reduce verbosity
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
Purpose
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
log4j
settings - Local 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.
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
.
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%n
For 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
.
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
:
# format: source.level<TAB>target
local0.none /var/log/messages
Documentation 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/messages
or/var/log/syslog
, for the Bamboo entries. The lines are formatted as follows:Aug 9 23:39:31 my.server.hostname myprogram[pid]: log entry
Using the
programname
from the log, add the following lines to yourrsyslog.conf
:rsyslog.confif $programname startswith 'myprogram' then /var/log/bamboo.log & stop
The second line excludes everything else that matches the same
if
condition.
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
)