I am entirely new to this syslog-ng concept and trying to do some logging of my application using syslog-ng levels into different files.
ie.) LOG_ALERT log should be generated into alert.log file and Log_INFO log should be generated into info.log file
I have tried to modify the syslog-ng.conf file for separation files based on levels, where I am not sure about the modification I had done is correct.
I had a look on to this question, where I am not able to understand the answer Writing in separate log files
Following is the syslog-ng.conf I have modified
@version: 3.2
@include "scl.conf"
source s_local {
system();
internal();
};
source s_LOG_ALERT {
system();
internal();
};
source s_network {
udp();
};
destination d_local {
file("/var/log/messages.txt");
};
destination d_LOG_ALERT {
file("/var/log/alert.txt");
};
log {
source(s_LOG_ALERT);
destination(d_LOG_ALERT);
};
log {
source(s_local);
# uncomment this line to open port 514 to receive messages
#source(s_network);
destination(d_local);
};
After this modification, I had observed that the log is entirely generating in the only messages.txt file, but not in alert.tx.
Following is the sample C code I have used
openlog("myapp",LOG_CONS|LOG_PID|LOG_NDELAY,LOG_LOCAL0);
syslog(LOG_ALERT|LOG_LOCAL0,"Alert",getuid());
syslog (LOG_ALERT, "Program started by User %d \n", getuid ());
syslog (LOG_ALERT , "Its the Beginning ");
syslog (LOG_ALERT , "Hello ALL ");
syslog (LOG_ALERT , "Its the alert ");
syslog (LOG_INFO , " Information for all ");
syslog (LOG_INFO, " Simulation has begin ");
followed by my application code.
Any leads would be very helpful.