Kajal Kajal - 1 year ago 78
C Question

rsyslogd issues , logged with openlog () but logs going to /var/log/messages

i have a c program the code is

setlogmask (LOG_UPTO (LOG_NOTICE));
openlog ("thelog", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
syslog (LOG_NOTICE, "thelog : started by User %d", getuid ());
syslog (LOG_INFO, "thelog: an info is logging");

the code is working properly BUT the issue is the log is being logged to the file
/var/log/messages , i have /etc/rsyslog.conf no and syslog.conf

I want the logs to be logged to a new file /var/log/thelog.log file

how to fix this issue .

fvu fvu
Answer Source

If you want LOCAL1 to be logged to a separate file you

  1. tell syslog so by properly editing its config file
  2. have syslogd reload its config by sending a kill -HUP.


Add a specific line for local1, like this one

local1.*                -/var/log/thelog.log


*.*;mail.none;news.none    -/var/log/messages

and remove local1 from the configuration for local?.*

local0.*              -/var/log/localmessages
local2,local3.*       -/var/log/localmessages

Once the configuration file is ready

kill -HUP <pid-of-syslogd>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download