I have an application that generates logs to a file, but it doesn't provide any log rotation strategy and fills up the disk quickly. (Why so? I am still figuring it out)
To mitigate this I have 3 options:
Add support for log rotation - For some reason this would take a lot of time and would not prefer now
use Linux logrotate - I can use this and this will rotate and purge log files
Simply publish the logs to /dev/stdout instead of to a file - In my assumption this is not gonna take any disk space and will do my job
If we skip point 2nd for time being, I am trying to understand the cons of writing logs to stdout instead of to a file.
Few more info:
- number of logs published per sec is a couple of thousands
- The log published to file or stdout will be shipped by a separate process to ELK/logstash
I know the best and simple approach would be to support log rotation/purging within the application, however, can someone kindly help me understand the pros and cons of using stdout vs file for logging.
I am relatively new to this concept, any help or pointer to the right document would be really helpful.
System.out
?docker logs
work and you can point the external log collector at the container system.System.out
in Java are painfully slow (cf. this benchmark). That is why logging to a file is more current.