Score:0

Apache2 writes to /dev/stdout instead of /var/log/apache2/access.log (using docker)?

cl flag

I am running apache2 2.4.10 in a debian docker container using below docker-compose file:

version: '3.8'
services:
  apache2-php:
    container_name: apache2-php-container
    image: apache2-php-image
    build:
      context: ./docker/apache2
    ports:
      - "8082:80"
    volumes:
      - ./docker/apache2/index.php:/var/www/index.php
 

with this site.

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName localhost
    ServerAlias localhost
    DocumentRoot /var/www
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Its up an running just fine but for some reason logs are written to stdout/stderr instead of above specified files. Also I see:

$ ls -la /var/log/apache2
total 8
drwxrwxrwx 2 www-data www-data 4096 Dec 29  2018 .
drwxr-xr-x 1 root     root     4096 Dec 29  2018 ..
lrwxrwxrwx 1 www-data www-data   11 Dec 29  2018 access.log -> /dev/stdout
lrwxrwxrwx 1 www-data www-data   11 Dec 29  2018 error.log -> /dev/stderr
lrwxrwxrwx 1 www-data www-data   11 Dec 29  2018 other_vhosts_access.log -> /dev/stdout

Do I need to add some option in my site to force apache2 to write to the actual files instead of to stdout/stderr?

Score:0
cc flag

For some reason those are symlinks to the device files for stdout and stderr. To make Apache write to actual files, you simply need to remove the symlinks and restart Apache:

sudo rm /var/log/apache2/{access,error,other_vhosts_access}.log
sudo systemctl restart apache2
cl flag
Sorry was leaving out the docker details since I assumed it was irrelevant but could this be cause by some docker convention that logs are always written to stdout unless something explicit config is set - if possible?
cc flag
I couldn't say, I'm not familiar with Docker.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.