How to configure log rotation for Embedded Elasticsearch in Bitbucket server

Still need help?

The Atlassian Community is here for you.

Ask the community

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


This article describes how to configure log rotation for an embedded Elasticsearch instance that is installed alongside Bitbucket Server. The configuration below configures rotation in such a way that the bitbucket-search.log file will be rotated every time it exceeds 25MB in size. The maximum number of log files retained for a single day is set to 10. Both parameters (size and number of files) can be configured as needed. This approach has been tested with Elasticsearch instances that are bundled with Bitbucket Server, however this should also work with a standalone Elasticsearch instance, such as when using Bitbucket Data Center.


Elasticsearch version 5 and newer
Bitbucket Server version 7.x


Here are the steps to implement size-based log rotation for ES

  1. Navigate to <Bitbucket_Home>/shared/search. You should see a file named
  2. Edit the  file and remove or comment out (by prefixing them with #)the following lines:
    appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}.log
    appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
    appender.rolling.policies.time.interval = 1
    appender.rolling.policies.time.modulate = true
  3. Then add the following lines:
    appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.log
    appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
    appender.rolling.policies.size.size = 25MB
    appender.rolling.strategy.type = DefaultRolloverStrategy
    appender.rolling.strategy.max = 10
  4. Restart Bitbucket Server, which will restart the bundled Elasticsearch instance. If you are attempting to apply this configuration to a standalone Elasticsearch instance, you do not need to restart Bitbucket Server, but will need to restart Elasticsearch manually. Once the restart is complete, Elasticsearch will be rotating files as configured, and once the log file has reached the configured threshold, you should be seeing multiple log files in the log directory, such as the ones below.

Last modified on Feb 8, 2022

Was this helpful?

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