Hello to everyone! I have a question about syslog.
I want put the messages of log in a particular file
but really i don't know how to do that or i don't get the results
that I want.
I do this:
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
int main (void)
{
openlog("Test",LOG_PID,LOG_USER);
syslog(LOG_INFO,"LOG!!");
closelog();
}
And in 50-default.conf I add this line
if $programname=='Test' then /home/me/var.log
But the file var.log is empty after i ran the program (Obviously I do a rsyslogd restart before run the program).
What is wrong with this?
Bye!
have you tried putting a space on either end of ==
?
if $programname == 'Test' then /home/me/var.log
No still not working.
The file that I modified is /etc/rsyslog.d/50-default.conf
It is right?
Thank you
oh i don't know i don't have a split config. I assume you have $IncludeConfig /etc/rsyslog.d/*.conf
in your /etc/rsyslogd.conf? And that you didn't add the rule within another rule?
To be honest I've never used the expression-based scripting of rsyslogd. If a program needs its own separate log file, usually it will handle it on its own rather than use the syslog.
Oh...ok. I only supossed that the correct way is use syslog , cause is a daemon built for that.
Thank you for all.