I've always done this, never have I used a library for this, because:
- running manually? >myapp.log 2>&1
- using systemd? use journalctl
- using docker/kubernetes? capture automatically the stdout/stderr of your containers and pipe them through logstash or something
Real question: why would an application need to know where its logs go? This is not in the business perimeter, but the ops perimeter. Am I wrong?EDIT:
Most responses are about configuring logging level, output format, etc... This can be done with a print-based approach without sending a request to an external service (which would need to trust you and your inputs).
Example: Python's default logging module.
Still, thank you for your insightful answers :)