Closed rumski20 closed 2 years ago
When you specify /var/log/apache2/access.log
, you end up with your logs going to a file inside the container -- here's the relevant CustomLog
line from the image:
$ docker run --rm httpd grep ' CustomLog' conf/httpd.conf
CustomLog /proc/self/fd/1 common
If you want to access the logs via docker logs
, you'll want to replicate this so the logs go to the container's stdout instead of to a file.
Okay, thank you for posting that code. It helped me dig in a little deeper.
I know this might qualify as a separate issue, but my ultimate goal is to have the apache container write logs to files on the host using the combined format.
To this end I cloned the repo and commented out the lines that I thought were sending logs to stdout. And then I specified a bind mount for where I thought the container would be writing the logs, with the intention of being able to access these files on the host:
volumes:
# log files
- /path/on/host/apache_logs:/var/log/apache2
However, when I run the code you posted above on my image, I get the following output:
CustomLog "logs/access_log" common
I don't know where this configuration comes from. And when I remote into the container I can't find any directory or file named access_logs
.
The only logs
directory is at /usr/local/apache2/logs
. And it only contains the httpd.pid
file.
Thanks for any guidance you can provide.
I would suggest trying a dedicated support forum, such as the Docker Community Forums, the Docker Community Slack, or Stack Overflow for more help debugging the details of what's going wrong here.
If you want to completely disable our logging changes, you'll want to remove all three of these lines:
(Or revert them in your own configuration, which would allow you to avoid compiling httpd
from source.)
I am trying to get Apache to output using the combined format for my access log.
In my
httpd.conf
file I have this configuration for access logging:I believe it's unchanged from the defaults.
However, when I run
docker logs <apache-container>
I don't get the referer or user-agent information in the log entries (I also get duplicate lines for each request, but that's probably a separate issue).What do I need to do to get that information output in the log entries?
Thanks.