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?