Configure Apache in the container to log to a file instead of stdout

The default configuration in the docker image for the apache tagged container is that the access_log and error_log are redirected to /dev/stdout. Is there any option to alter this via environmental variables? I want to collect the logs directly for some security analysis. I’m loathe to correct the configuration directly in the container. I don’t want to just collect the container logs directly because it potentially has other stuff. I really want JUST the Apache logs to analyze.

This thread, while technically to do sort of the opposite, should give you some hints:

Essentially your choices are these:

  1. Quick change (that won’t persist necessarily) in-container [manual modification of either symbolic links or existing config]
  2. Change the Dockerfile (i.e. add removal of the symbolic links) [i.e. custom image]
  3. Bind mount an overriding Apache config to your container to adjust where logging goes
2 Likes