I'm running Apache2 in a docker container, and want to write nothing to the disk, writing logs to stdout and stderr. I've seen a few different ways to do this (Supervisord and stdout/stderr, Apache access log to stdout) but these seem like hacks. Is there no way to do this by default?
To be clear, I do not want to tail the log, since that will result in things being written to the disk in the container.
works on ubuntu and centos fo me
How about placing this in your Dockerfile after the apache2 package is installed?
Assuming that this is the path of the logs. It is for Ubuntu 14.04 and also works for Ubuntu 16.04.
Note: if you're certain that the symbolic links
/dev/stdout
or/proc/stderr
are there, then you may also use those. I prefer the path to the real file as this is guaranteed present.Not specifically an answer asked for but maybe a better way, depending on your scenario, would be to to not log to stdout/stderr at all. Just pipe the logs to cat in a JSON format. This would remove the need to differentiate the streams as the json could have the data needed in it to distinguish them. eg something along the lines of the following. This can then be ingested much more easily into something like graylog
There is also a gelf logging module, so you can stream direct from apache to a graylog type server as well if you wish