Configure Bitbucket Server Logging

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

プラットフォームについて: Server と Data Center のみ - この記事は、サーバーおよびデータセンター プラットフォームのアトラシアン製品にのみ適用されます。

目的

Bitbucket Server holds on to atlassian-bitbucket.log for 31 days by default. Similarly, atlassian-bitbucket-access.log files are kept for 10 days and they are also rotated through the day in case they reach 25MB.

It is sometimes useful for Bitbucket Server administrators to change the number of days logs are kept or the size of those individual log files. 

注意:

  • The files you are about to modify are maintained in the <Bitbucket Server Installation> directory, so these changes will need to be re-applied manually when Bitbucket Server is upgraded. Do not copy this modified file into the new installation.
  • A Bitbucket Server restart after these changes have been made is mandatory.
  • For versions of Bitbucket prior to 7.0, the file to modify will be named logback.xml instead of logback-spring.xml.

ソリューション

These sorts of modifications can be accomplished by editing <Bitbucket Server Installation>/atlassian-bitbucket/WEB-INF/classes/logback-spring.xml (or logback.xml if you are using a Bitbucket version prior to 7.0).

Modify the appenders by adding / editing the max_history and maxFileSize attributes and also modifying the rollingPolicy class accordingly.

These are the default settings:

<appender name="bitbucket.application" class="ch.qos.logback.core.rolling.RollingFileAppender">
	<encoder>
		<charset>UTF-8</charset>
		<pattern>${log.format}</pattern>
	</encoder>
	<file>${log.dir}/atlassian-bitbucket.log</file>
	<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
		<fileNamePattern>${log.dir}/atlassian-bitbucket-%d.log</fileNamePattern>
		<maxHistory>31</maxHistory>
	</rollingPolicy>
</appender>

...
...
 
<appender name="bitbucket.accesslog" class="ch.qos.logback.core.rolling.RollingFileAppender">
	<encoder>
		<charset>UTF-8</charset>
		<pattern>${accesslog.format}</pattern>
	</encoder>
	<file>${log.dir}/atlassian-bitbucket-access.log</file>
	<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
		<fileNamePattern>${log.dir}/atlassian-bitbucket-access-%d.%i.log</fileNamePattern>
		<maxHistory>10</maxHistory>
		<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
			<maxFileSize>25MB</maxFileSize>
		</timeBasedFileNamingAndTriggeringPolicy>
	</rollingPolicy>
</appender>

If you want to make the atlassian-bitbucket.log rotate not only in a daily basis, but also whenever it reaches 25MB within the same day, and keep the logs from the last 31 days, you need to do these modifications to the bitbucket.application appender:

  • Modify TimeBasedRollingPolicy by SizeAndTimeBasedRollingPolicy (in line #30 by default)
  • Modify the fileNamePattern from atlassian-bitbucket-%d.log to atlassian-bitbucket-%d.%i.log (in line #31 by default)
  • Add the maxFileSize element inside the rollingPolicy element

This is a working example containing the two changes mentioned above:

<appender name="bitbucket.application" class="ch.qos.logback.core.rolling.RollingFileAppender">
	<encoder>
		<charset>UTF-8</charset>
		<pattern>${log.format}</pattern>
	</encoder>
	<file>${log.dir}/atlassian-bitbucket.log</file>
	<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
		<fileNamePattern>${log.dir}/atlassian-bitbucket-%d.%i.log</fileNamePattern>
		<maxHistory>31</maxHistory>
		<maxFileSize>25MB</maxFileSize>
	</rollingPolicy>
</appender>

Compressing log files:

If you want to gzip any of the logs automatically on their rotation, you could change the line above and add .gz as an extension:

<fileNamePattern>${log.dir}/atlassian-bitbucket-%d.log.gz</fileNamePattern>

または

<fileNamePattern>${log.dir}/atlassian-bitbucket-access-%d.%i.log.gz</fileNamePattern>

Modifying the output format of log messages

It is possible to adjust the output format of log messages that are written by each individual appender - such as changing the date format, or un-abbreviating the package names in each log entry.

Check out this article for more information relating to these types of modifications.


最終更新日: 2020 年 10 月 7 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.