I successfully tested the following syslog “hello world” example on ubuntu 12.04:
// gcc giuspexample.c -o giuspexample
#include <syslog.h>
int main()
{
setlogmask(LOG_UPTO (LOG_NOTICE));
openlog("atm", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL0);
syslog(LOG_NOTICE, "Program started by User %d", getuid ());
syslog(LOG_INFO, "A tree falls in a forest");
closelog();
return 0;
}
and I can read the entry in /var/log/syslog.
I followed the instructions on http://www.codealias.info/technotes/syslog_simple_example on how to change the destination filepath
echo "local0.* /var/log/mylog" >> /etc/syslog.conf
but trying to run
sudo /etc/init.d/syslog restart
doesn’t work (command not found) and rebooting the pc anyway doesn’t start to write on /var/log/mylog but still on /var/log/syslog.
Does anybody know what’s wrong?
Thanks.
In the
/etc/rsyslog.ddirectory, there are two files:20-ufw.conf50-default.confI added the file
/etc/rsyslog.d/30-mycustomname.confwithsudo nano, with the following content:Then I check that the file
/var/log/centro.logdoes not existThen I restart the service
Finally The following code works: