New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where is the error.log? #212

Closed
keltik85 opened this Issue Apr 1, 2016 · 7 comments

Comments

Projects
None yet
6 participants
@keltik85

keltik85 commented Apr 1, 2016

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?????

@tdutrion

This comment has been minimized.

Show comment
Hide comment
@tdutrion

tdutrion Apr 1, 2016

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.

tdutrion commented Apr 1, 2016

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.

@blueimp

This comment has been minimized.

Show comment
Hide comment
@blueimp

blueimp Apr 2, 2016

@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

blueimp commented Apr 2, 2016

@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

@keltik85 keltik85 closed this Apr 5, 2016

@povils

This comment has been minimized.

Show comment
Hide comment
@povils

povils May 17, 2017

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

povils commented May 17, 2017

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

@Raaghu

This comment has been minimized.

Show comment
Hide comment
@Raaghu

Raaghu May 29, 2017

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

Raaghu commented May 29, 2017

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

@mikesparr

This comment has been minimized.

Show comment
Hide comment
@mikesparr

mikesparr Oct 20, 2017

@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.

mikesparr commented Oct 20, 2017

@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.

@povils

This comment has been minimized.

Show comment
Hide comment
@povils

povils Oct 20, 2017

@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

povils commented Oct 20, 2017

@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

@mikesparr

This comment has been minimized.

Show comment
Hide comment
@mikesparr

mikesparr Oct 20, 2017

mikesparr commented Oct 20, 2017

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