Maxximiliann
Auto rotating logs by file size
Installed:
logrotate for Ubuntu (config file)
Trying to get logs to automatically rotate when they hit 125MB with logrotate to no avail. How can logs be automatically rotated straight from Elixir?
Marked As Solved
derek-zhou
What I meant is:
config :myapp, :logger,
[
{:handler, :my_disk_log, :logger_disk_log_h,
%{config: %{file: 'test.log',
max_no_bytes: 100_000_000},
level: :info}
}
]
Untested, but you get the idea. It is a 2 level map, and each have it own set of keys. The outer level is the general configuration for any log_handler, the inner one is the configuration specifically for :logger_disk_log_h
Also Liked
derek-zhou
derek-zhou
I was referring to this sentence in the changelog. Probably “internal” does not mean non-public:
The standard logger handler, logger_std_h, now has a new internal feature for log rotation.
As for filename rotation, I prefer the scheme of svlogd from runit, which is somewhere between the two:
- lastest file name is fixed
- old files are not renamed
On one hand I want the latest file easily identifiable. On the other hand, I prefer old files just stay what they are. If something went wrong and the log files are rotating fast it is very frustrating to pin down the one file that has the log entries you want to analysis.
hauleth
Probably “internal” does not mean non-public
It meant how it is implemented, not about “publicity” of an API.
I prefer the scheme of svlogd from runit
It seems like more reasonable approach, indeed. However changing it now would be a breaking change. However I hope that logger_olp and logger_sup will became public API in near future, which mean that there will be a way to implement such feature directly in Erlang. However personally I still prefer to use syslog or journal for logging, and do not bother with rotation within the application itself. In that way, there is no problem with rotation or “where will logs land” as you have centralised place to manage everything.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









