One of decisions that has to be made regarding logging is the choice of logging output. From my experience the decision largely depends on the application type. Please take notice that even though I have been creating apps in all of the listed types, it does not mean I am expert in any of those.
Console Application (aka CLI App)
Use stderr for logging output as this is the stream which should be used for diagnostics by design.
Any other logger output (usually file) may be configured via command-line arguments or configuration file. However in most cases it is not needed.
Graphical Application (aka GUI App)
Rotating files in /var/log in case of *NIX system (e.g. Linux, BSD, MacOS) or user’s local Application Data directory for Windows is usually the most popular choice.
Network Application (e.g. Web App, Web Service, Microservice)
The Twelve-Factor App recommends to use stdout. It is an excellent approach when you using containers.
Agent (*NIX Deamon or Windows Service)
Use Syslog for *nix. Use Windows Event Log or (rarely) Windows Event Tracing (ETW) for Windows.
Additionally, consider to also log to rolling files. While logging to Syslog or Event Log is great for administrators and computer systems, the rolling file is extremely helpful when diagnostics are needed from causal users for troubleshooting.
Microcontroller Program
Most frequently we store the logs in a rotating files on SD card. However, it can be also be done via UART, SPI, USB communication if it is connected to a (micro)computer together with some deamon that logs the input.
Distributed System
When working with a distributed system (even if it is only multiple instances of a single web application), it is a good practice to sends logs to a centralized Log Management systems like Elasticsearch, GrayLog, Loggly.
Take notice that usually you should log to stderr and use additional tools like a Log Collector (FileBeat, Logstash, Fluentd), Docker logging drivers or even systemd or supervisord to pipe your logs to your preferred destination instead of hard-coding it into the application.
There is also a great documentation describing how to configure logging using Kubernetes.