New Logger in Erlang
https://ferd.ca/erlang-otp-21-s-new-logger.html
- OTP-21 -> new logging library in Erlang -
logger
- an alternative and “result” of
lager
library
- STRUCTURE
- you should not know the structure of
logger
to use it. But to extend - you should
logger
exposes 3 types of components with well-defined interfaces
- Log Filters
- Log Handlers
- Log Formatters
- These elements are in config database (ETS -> cheap)
- You want to log asap (move everything to another process).
- For Erlang (preemptive concurrency) logger might be a bottleneck:
- => we want to distribute this work as much as possible at the call-site
- quick -> will not be noticeable
- as logger-configuration is ready for concurrent reading -> easy to implement
- DATA FLOW
- check level, get logger config
- apply general filters, apply handlers (+filters +formatters)
- skip logging on any level
- disk logging - one process that handle a file descriptor
- GOOD LOGGING
- log what you know/observe, not your deductions (ssl problems -> “your system is hacked”)
- single way to produce logs -> auto dispatch to different storage based on content
- structured logs (maps of maps -> handler to flatten or json them)
- MORE
- distributed tracing work nicely with the logger
- metrics from log - too
- which fields logs should contain (table)