Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

How redirect syslog message to a specified file?

$
0
0
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:

Code:

#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

Code:

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!

Viewing all articles
Browse latest Browse all 16232

Trending Articles