4

i'm trying to dockerize my php application. I have a container for NGINX and PHP-FPM.

My application writes some log data to the syslog via the PHP openlog and syslog functions like this:

openlog("myapp.test", LOG_ODELAY | LOG_CONS, LOG_LOCAL5);
syslog(LOG_INFO, "This is a test");
closelog();

My docker daemon is configured to use the syslog driver:

{
    "graph": "/storage/docker-service",
    "storage-driver": "overlay",
    "log-driver": "syslog",
    "log-opts": {
        "syslog-address": "tcp://SERVER_IP:514",
        "syslog-facility": "local5"
    }
}

(SERVER_IP is the IPv4 address of my server)

I start my docker container with docker-compose and only set the log-tag with the logging options for each container.

NGINX is configured to log to the syslog:

error_log syslog:server=SERVER_IP,facility=local5,tag=nginx debug;
access_log syslog:server=SERVER_IP,facility=local5,tag=nginx;

PHP-FPM the same:

error_log = syslog
syslog.ident = php-fpm
syslog.facility = local5

The logs from NGINX and PHP-FPM are shown correctly in the servers syslog. But the log messages created with the php functions never appear.

What is the problem here? Think using the docker syslog driver catches all syslog messages within the containers?

Any suggestion how to fix this?

elpado
  • 63
  • 1
  • 6
  • Can you try including LOG_PERROR option in openlog so that logs also go to stderr which allows docker daemon to redirect it to syslog server. – Sreeni Jun 09 '17 at 13:49
  • 1
    I finally got it working by mounting /dev/log from local maschin to the container at the same Place. -v /dev/log:/dev/log This way calls from php syslog function appear in the syslog of my local maschin. Next week i`m back in the office and will give LOG_PERROR a try. – elpado Jun 10 '17 at 14:45

0 Answers0