Skip to content

Where is the error.log? #212

Closed
Closed

Description

@keltik85

Hi,

I need some advice from more seasoned docker users.

I am extending the official php-image in my Dockerfile like this:

 FROM php:5.6-apache
        MAINTAINER "John Doe <Johndoe@dough.com>"
        COPY ./templates/apache2files/piwik /var/www/html/
        COPY ./templates/php.ini /usr/local/etc/php/
        RUN chmod 777 -R /var/www/html/
        RUN docker-php-ext-install mysqli
        RUN docker-php-ext-install mbstring

I build the dockerfile with this:

docker build -t mypiwik

I run the container like this:

docker run -d --name mypiwikcontainer -p "8888:80" mypiwik:latest

I can see the access.log using this:

docker logs mypiwikcontainer

How can I see the error.log?????

Activity

  1. tdutrion commented on Apr 1, 2016

    @tdutrion

    Hi,

    What have you got in your logs? (docker logs mypiwikcontainer)

    Currently I have the following (version 7.0-apache):

    [core:warn] [pid 1] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
    

    Therefore, there might be no file, unless I actually set this variable (currently investigation).

    Also, you do not need to access the file. You can probably read it by connecting with ssh (docker exec -it mypiwikcontainer /bin/bash), and then access the right directory and use less or whatever is installed. I would personally use docker logs and am trying to get into the log drivers to centralise logs to a central graylog instance.

  2. blueimp commented on Apr 2, 2016

    @blueimp

    @keltik85
    I had the same issue and solved it the following way:

    In your php.ini, add the following lines:

    log_errors = On
    error_log = /dev/stderr
    

    Now you'll be able to see any PHP error logs as part of the docker container log stream:

    docker logs -f your_php_apache_container

    To display only errors and hide the access log, you can pipe stdout to /dev/null:

    docker logs -f your_php_apache_container >/dev/null

    To follow only the access log, you can pipe stderr to /dev/null:

    docker logs -f your_php_apache_container 2>/dev/null
  3. povils commented on May 17, 2017

    @povils

    It's cool, but how to get actual log files?

  4. Raaghu commented on May 29, 2017

    @Raaghu

    check that 000-default site is enabled for your apache,
    in my case /etc/apache2/sites-enabled/ does not contained softlink to 000-default.conf

    so I ran

    a2ensite 000-default
    apache2ctl restart
    

    then i started seeing logs in access.log and error.log

  5. mikesparr commented on Oct 20, 2017

    @mikesparr

    @povils Container apps shouldn't write log files in the container, as its lifecycle is meant to be "disposable", unless you mount a volume and want them on your file system. This is a core tenet of the 12-factor-app methodology.

    If you docker exec -it app-name ls -alh /var/log/apache2/ you will see the log files are symlinked to /dev/stderr and /dev/stdout as they should. This allows the container engine to expose logs via the docker logs -f app-name command or an orchestrator like Swarm or Kubernetes to expose them to centralized logging like ELK stack or Stackdriver.

  6. povils commented on Oct 20, 2017

    @povils

    @mikesparr Thanks for the answer. I needed log files because I am using Elastic Filebeat which harvests log files and streams that to our ELK

  7. mikesparr commented on Oct 20, 2017

    @mikesparr
  8. okainov commented on May 11, 2019

    @okainov

    @blueimp thanks, works perfectly! I wonder, why isn't it included into default PHP Docker image....

  9. buster95 commented on Apr 23, 2020

    @buster95

    I solved this problem adding next command in dockerfile

    RUN cp $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini
  10. Videles commented on Apr 26, 2022

    @Videles

    @keltik85 I had the same issue and solved it the following way:

    In your php.ini, add the following lines:

    log_errors = On
    error_log = /dev/stderr
    

    Now you'll be able to see any PHP error logs as part of the docker container log stream:

    docker logs -f your_php_apache_container

    To display only errors and hide the access log, you can pipe stdout to /dev/null:

    docker logs -f your_php_apache_container >/dev/null

    To follow only the access log, you can pipe stderr to /dev/null:

    docker logs -f your_php_apache_container 2>/dev/null

    This works like a charms, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions