Migrating custom logging configurations to Log4j 2

Still need help?

The Atlassian Community is here for you.

Ask the community

In Bamboo 9.0, we’ve upgraded the Log4j runtime logging library to version 2. This means that if you’re using a custom Log4j 1.x configuration with your Bamboo instance, you’ll need to manually migrate it to the Log4j 2 configuration file format. This guide describes the necessary steps to complete the migration and provides examples to help you along the way.

If you didn’t customize the logging configuration of your Bamboo instance or remote agents before upgrading to Bamboo 9.0, you can skip this page.

To learn more about what’s new in Log4j 2, see Apache Log4j 2.

On this page:

Step 1: Migrate logging level configurations

In the following example, we’ll migrate the MarketplaceClient class logging level configuration.

In Log4j 1.x, the logging level configuration for the MarketplaceClient class would look like this:

log4j.category.com.atlassian.marketplace.client.MarketplaceClient=WARN

The same configuration in Log4j 2 requires that we migrate the MarketplaceClient category configuration to a logger under the name marketplaceClient:

logger.marketplaceClient.level = WARN
logger.marketplaceClient.name = com.atlassian.marketplace.client.MarketplaceClient

As part of this migration, we gave the new logger the following properties:

  • level defines the logging level (in this case, the logging level is WARN)
  • name indicates the class we are configuring the logging level for (in this case, com.atlassian.marketplace.client.MarketplaceClient)

Step 2: Migrate Log4j appender configurations

Appender property definitions have also changed in Log4j 2. In the following example, we’ll migrate the BambooRollingFile appender with the same configuration as in Log4j 1.x.

This is what the BambooRollingFile appender configuration would look like in Log4j 1.x:

#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=100MB
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

And this is what the configuration should look like in a Log4j 2-compatible format:

#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

Step 3: Migrate custom logging configurations on remote agents

If you’re using custom logging configurations on your remote agents, migrate them to the Log4j 2-compatible format by applying the previous steps, and then change the remote agents' configuration parameters in wrapper.conf.

Under Log4j 1.x, the wrapper.conf file would point to the log4j.properties file by means of the log4j.configuration parameter:

wrapper.java.additional.4=-Dlog4j.configuration=/path/to/log4j.properties

Now, the parameter is called log4j2.configurationFile, so to make this work with Log4j 2, adjust the parameter name and value:

wrapper.java.additional.4=-Dlog4j2.configurationFile=/path/to/log4j2.properties
tip/resting Created with Sketch.

If your custom configuration has few changes over the original file, you might find it easier to start with a clean log4j2.properties file and customize it accordingly. Simply use the default Log4j 2 configuration file as a template, and migrate your custom configurations from the old properties file to the new one.

Show me the default contents of log4j2.properties...

Here’s an example of the default contents of the log4j2.properties file:

#
# Change the following line to configure the bamboo logging levels (one of INFO, DEBUG, ERROR, FATAL)
#
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

########################################################################################################################
# Access Log
########################################################################################################################
#using 'bamboo home aware' appender for access logs
appender.accesslog.type = BambooRollingFile
appender.accesslog.name = accesslog
appender.accesslog.fileName = atlassian-bamboo-access.log
appender.accesslog.filePattern = atlassian-bamboo-access.log.%i
appender.accesslog.layout.type = PatternLayout
appender.accesslog.layout.pattern = %d{DEFAULT} %p [%t] [%C{1}] %m%n
appender.accesslog.policies.type = Policies
appender.accesslog.policies.size.type = SizeBasedTriggeringPolicy
appender.accesslog.policies.size.size = 20MB
appender.accesslog.strategy.type = DefaultRolloverStrategy
appender.accesslog.strategy.max = 5
appender.accesslog.strategy.fileIndex = min

logger.accesslogfilter = INFO, accesslog, console
logger.accesslogfilter.name = com.atlassian.bamboo.filter.AccessLogFilter
logger.accesslogfilter.additivity = false

########################################################################################################################
# Emergency, high volume logging
########################################################################################################################
appender.emergency.type = BambooRollingFile
appender.emergency.name = emergency
appender.emergency.fileName = emergency-atlassian-bamboo.log
appender.emergency.filePattern = emergency-atlassian-bamboo.log.%i
appender.emergency.layout.type = PatternLayout
appender.emergency.layout.pattern = %d{DEFAULT} %p [%t] [%C{1}] %m%n
appender.emergency.policies.type = Policies
appender.emergency.policies.size.type = SizeBasedTriggeringPolicy
appender.emergency.policies.size.size = 20480KB
appender.emergency.strategy.type = DefaultRolloverStrategy
appender.emergency.strategy.max = 5
appender.emergency.strategy.fileIndex = min

logger.emergency=INFO, emergency
logger.emergency.name = emergency
logger.emergency.additivity = false

########################################################################################################################
# Javascript Debugging
########################################################################################################################
appender.javascript.type = BambooRollingFile
appender.javascript.name = javascript
appender.javascript.fileName = js-atlassian-bamboo.log
appender.javascript.filePattern = js-atlassian-bamboo.log.%i
appender.javascript.layout.type = PatternLayout
appender.javascript.layout.pattern = %d{DEFAULT} %p [%t] [%C{1}] %m%n
appender.javascript.policies.type = Policies
appender.javascript.policies.size.type = SizeBasedTriggeringPolicy
appender.javascript.policies.size.size = 20480KB
appender.javascript.strategy.type = DefaultRolloverStrategy
appender.javascript.strategy.max = 5
appender.javascript.strategy.fileIndex = min

logger.javascript=DEBUG, javascript
logger.javascript.name = JavaScript
logger.javascript.additivity = false

########################################################################################################################
# Database Logging
########################################################################################################################
logger.SessionImpl.level=ERROR
logger.SessionImpl.name=org.hibernate.impl.SessionImpl
#Remove when criteria queries are mostly gone
logger.hibernate-deprecation.level=ERROR
logger.hibernate-deprecation.name=org.hibernate.orm.deprecation
#Remove when most entities are on annotations instead of hbms
logger.MetadataContext.level=ERROR
logger.MetadataContext.name=org.hibernate.metamodel.internal.MetadataContext

## log hibernate prepared statements/SQL queries (equivalent to setting 'hibernate.show_sql' to 'true')
#logger.sql.name = org.hibernate.SQL
#logger.sql.level= DEBUG

## log hibernate prepared statement parameter values
#logger.hibernate-type.name=org.hibernate.type
#logger.hibernate-type.level=TRACE
#logger.hibernate-batcher.name=org.hibernate.impl.BatcherImpl
#logger.hibernate-batcher.level=DEBUG

## log active objects sql statements
#logger.ao-sql.name=net.java.ao.sql
#logger.ao-sql.level=DEBUG

## Bamboo plan cache detailed logging
#logger.plan-cache.name=com.atlassian.bamboo.plan.cache
#logger.plan-cache.level= DEBUG

########################################################################################################################
# OSGi and Atl plugins related logs
########################################################################################################################
logger.FelixOsgiContainerManager.level=WARN
logger.FelixOsgiContainerManager.name = com.atlassian.plugin.osgi.container.felix.FelixOsgiContainerManager
logger.ExportPackageListBuilder.level=ERROR
logger.ExportPackageListBuilder.name = org.twdata.pkgscanner.ExportPackageListBuilder
logger.atlassian-plugin.level=WARN
logger.atlassian-plugin.name = com.atlassian.plugin
logger.streams.level=WARN
logger.streams.name=com.atlassian.streams

########################################################################################################################
# SSH proxy related settings
########################################################################################################################
logger.sshd.level=WARN
logger.sshd.name=org.apache.sshd
logger.plugin-ssh.level=WARN
logger.plugin-ssh.name = com.atlassian.bamboo.plugins.ssh
logger.bamboo-ssh.level=WARN
logger.bamboo-ssh.name=com.atlassian.bamboo.ssh

########################################################################################################################
# General ignore logging for various packages
########################################################################################################################
logger.marketplaceClient.level = WARN
logger.marketplaceClient.name = com.atlassian.marketplace.client.MarketplaceClient
logger.webwork.level=WARN
logger.webwork.name = webwork
logger.velocity.level=WARN
logger.velocity.name = velocity
logger.xwork-util.level = ERROR
logger.xwork-util.name = com.opensymphony.xwork2.util
logger.springframework.level = WARN
logger.springframework.name = org.springframework
logger.hibernate.level = WARN
logger.hibernate.name = org.hibernate
logger.acegi.level = WARN
logger.acegi.name = org.acegisecurity
logger.activemq-failover.level = WARN
logger.activemq-failover.name = org.apache.activemq.transport.failover.FailoverTransport
logger.servlet-filter.level = WARN
logger.servlet-filter.name = com.atlassian.plugin.servlet.filter.ServletFilterModuleContainerFilter
logger.plugin-resource-download.level = WARN
logger.plugin-resource-download.name = com.atlassian.plugin.servlet.PluginResourceDownload
logger.ignore-missing-field-xstream.level = INFO
logger.ignore-missing-field-xstream.name = com.atlassian.bamboo.persister.xstream.IgnoreMissingFieldXStream
logger.dependency-resolver.level = ERROR
logger.dependency-resolver.name = com.atlassian.plugin.webresource.DefaultResourceDependencyResolver
logger.apache.level = INFO
logger.apache.name = org.apache
logger.botocss.level = WARN
logger.botocss.name = com.atlassian.botocss
logger.amazonaws.level = WARN
logger.amazonaws.name = com.amazonaws
logger.amazonaws-ec2metadatautils.level = ERROR
logger.amazonaws-ec2metadatautils.name = com.amazonaws.util.EC2MetadataUtils
logger.vutbr-web.level = WARN
logger.vutbr-web.name = cz.vutbr.web

# Embedded Crowd
logger.crowd.level = WARN
logger.crowd.name = com.atlassian.crowd

# log S3 retries
logger.s3.name=com.amazonaws.services.s3
logger.s3.level=INFO

logger.struts2-beanselection.name=org.apache.struts2.config.BeanSelectionProvide
logger.struts2-beanselection.level=WARN

logger.tunnel.name=com.atlassian.tunnel
logger.tunnel.level=WARN

# Docker client
logger.docker.name=com.spotify.docker.client
logger.docker.level = WARN

# profiling (needs system property -Datlassian.profile.activate=true to be activated)
logger.profiling.name=com.atlassian.util.profiling
logger.profiling.level=DEBUG

#upm cache flushes
logger.upm-stacktrace.name=com.atlassian.cache.stacktrace
logger.upm-stacktrace.level=WARN

Once you’ve completed all the steps above, your custom configuration should be perfectly compatible with Log4j 2.


Last modified on Aug 31, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.