0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【2023年11月版】Spring Boot 3 で Tomcat のアクセスログ出力をする

Posted at

はじめに

Spring Boot で Tomcat 側のアクセスログを出力したいな。
設定追加だけでいけるっしょ!
。。。からハマリがありました。

環境

  • Spring Boot 3 (3.1.x)
  • AmazonLinux 2023

結論

server.tomcat.basedir が設定されていないと動かない

server:
  tomcat:
    basedir: ./

手順

プロパティ設定一覧を見て、簡単に設定するだけで動くでしょ。

Spring アプリケーションプロパティ設定一覧

ChatGPTさんも、そのようにおっしゃってる。

ChatGPTさんの教えてくれた設定
server:
  tomcat:
    accesslog:
      enabled: true
      pattern: common
      directory: logs
      prefix: access_log
      suffix: .log
      rotate: true

動かしてみる。。。動かない。

basedirを加えてみる
server:
  tomcat:
    basedir: ./
    accesslog:
      enabled: true
      pattern: common
      directory: logs
      prefix: access_log
      suffix: .log
      rotate: true

動く、logs フォルダに、ログが出力されている。
basedir を設定しないと、一時ディレクトリが使用されるらしい。

ハマって、 server.tomcat の設定読み進めるまで、わかんなかった。

おわりに

かんたんでしたね

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?