Log Rotation Log rotation for your Hanami project
Log Rotation
By default, Hanami logger uses standard output because it’s a best practice that most hosting SaaS companies suggest using.
If you want to use a file, pass stream: 'path/to/file.log'
as an option.
Here’s how to setup daily log rotation:
# config/environment.rb
# ...
Hanami.configure do
# ...
environment :production do
logger "daily", level: :info, formatter: :json,
stream: "log/production.log"
# ...
end
end
If log/
directory is missing, it will be created at the server startup.
Alternatively, you can decide to put a limit to the number of files (let’s say 10
) and the size of each file (eg 1,024,000
bytes, aka 1
megabyte):
# config/environment.rb
# ...
Hanami.configure do
# ...
environment :production do
logger 10, 1_024_000, level: :info, formatter: :json,
stream: "log/production.log"
# ...
end
end
You can speficy arbitrary arguments, that are compatible with Ruby’s Logger
.
Learn more at https://guides.hanamirb.org/projects/logging/
Twitter Facebook