📈Log Level
Also known as Logging Level, Log Severity, Severity Level
A tag on each log line that says how serious it is.
Think of it like
It is like the volume knob on a radio. Turn it down and you only hear the loud parts.
Example
On her laptop, Emma logs at DEBUG to see every step. On the live server she sets WARN, so only warnings and errors are kept.
Why it matters
The right level keeps logs small enough to search and cheap enough to store.
Definition
Example code
python
import logging
logging.basicConfig(level=logging.WARNING)
logging.info("cart opened") # dropped
logging.error("payment failed") # kept: ERROR:root:payment failedCommon mistake
Key takeaways
- 1A ladder. From chatty DEBUG up to FATAL.
- 2A cut-off. Lines below the set level are dropped.
- 3Different per place. Chatty on a laptop, quiet when live.