- Kubernetes for Developers
- Joseph Heck
- 159字
- 2025-02-25 15:31:25
Sending output from your program
kubectl logs (as well as the Docker equivalent: docker logs) defaults to combining stdout and stderr and passing anything presented as logs for the container. You may have also had experience with creating specific logging capabilities in your code to write logs to a file location on disk. In general, writing logs to a filesystem location is not encouraged for software running within a container, as to include it in general logging means that something has to read it again, which unnecessarily increases disk I/O.
If you want to have a means of supporting aggregated logging in your application, then you will typically want to have something external to your container and/or Pod defined to help capture, transport, and process those logs.
In general, if you write your programs to log to stdout and stderr, then containers and Kubernetes running those containers will generally help you to get access to those details more easily.