Search code examples
phpdebiansyslog

Debian: Syslog - Create a own log file


I use PHP and want to log some functions of my script. I want to use syslog. I thought i can just add a new line in the /etc/rsyslog.conf file: application.* -/var/log/application.log

and log it like this with PHP:

define_syslog_variables();
openlog("upload", LOG_PID, LOG_APPLICATION);
syslog(LOG_DEBUG, "Test");
closelog();

but it don't work. There is no file called application.log


Solution

  • Two issues come to my mind regarding your problem:

    # 1 Have you restarted the sysklogd server after adding your application to the /etc/rsyslog.conf?

    /etc/init.d/sysklogd restart
    

    # 2 How is your php configured to log?

      -> php.ini   
      error_log = syslog