LoginSignup
0
0

More than 1 year has passed since last update.

【Ruby】Loggerライブラリを使用して一定サイズごとにログファイルを記録したい

Last updated at Posted at 2022-10-09

概要

一定のサイズごとにログファイルをローテートする場合には、
引数でローテーションするファイル数とサイズを指定する。
例えば5つのファイルを使い、1000バイトごとにローテーションさせる場合は以下のように指定する。

logger = Logger.new('test.log', 5, 1000) #5つのファイルを使い、1000バイトごとにローテーション

第2引数がローテートするファイル数、第3引数が1ファイルごとのサイズを指定できます。
上記の指定ですとログファイルが最新のものを除いて新しいものから順に番号が割り振られます。

  • 作られるログ
test.log
test.log.0
test.log.1
test.log.2
test.log.3

参考

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