LoginSignup
4
0

More than 5 years have passed since last update.

Spring Boot の Fully Executable Jar でログを出力させない方法

Posted at

はじめに

Spring BootのExecutable Jarを使ってプロジェクトを起動する場合、もともとのプロジェクト内でLogback等を使ってログを出力していると、LogbackとExecutable Jar の2つのログが出力されてしまう。
Spring BootのExecutable Jarの設定ファイルにはログの出力先、ログ名を設定する項目はあるが、ログの出力を制御する項目は無いらしい。
Spring BootのExecutable Jarのログを出さないようにするにはどうすればいいのだろうか・・・

解決方法

ずばり、「/dev/null」を使う

/dev/null とは?

/dev/null(nullデバイスとも呼ばれる)は、UNIXやUnix系OSにおけるスペシャルファイルの1つで、そこに書き込まれたデータを全て捨て、読み出してもどんなプロセスに対してもデータを返さない(EOFを返す)

設定方法

つまり、Spring Boot の Fully Executable Jarのログの出力先を「/dev/null」にすればいい

  • Spring BootのExecutable Jarの設定ファイル(/usr/local/xxx/xxx.conf)に以下を追加
xxx.conf
export LOG_FOLDER=/dev      #ログファイルの出力先フォルダ
export LOG_FILENAME=null    #ログファイル名

4
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
4
0