(L)ubuntu 12.04 syslog to custom file (not /var/log/syslog but /var/log/mylog) - ubuntu 12.04
Here's how I succeeded.
In my folder /etc/rsyslog.d there are two files:
20-ufw.conf and 50-default.conf
I added a file:
sudo nano /etc/rsyslog.d/30-mycustomname.conf
With the following content:
# Log QSD Centro generated log messages to file
if $programname == 'centro' then /var/log/centro.log
# Uncomment the following to stop logging anything that matches the last rule.
& ~
Then I check that the file /var/log/centro.log does not exist
sudo rm -f /var/log/centro.log
Then I restart the service
sudo service rsyslog restart
Finally The following code works:
// gcc centro.c -o centro
#include <stdio.h>
#include <syslog.h>
int main(int argc, char *argv[])
{
openlog(NULL, 0, LOG_USER);
syslog(LOG_INFO, "MORTACCI TUA!!!");
closelog();
return 0;
}
By default Ubuntu uses rsyslog. It's configuration files are in
/etc/rsyslog.conf
And
/etc/rsyslog.conf