* How to log the messages generated by c program using syslog-ng and how to manage log file rotation
@ 2014-08-05 14:40 Jean Faye
2014-08-06 9:08 ` Tr : Help - " Jean Faye
0 siblings, 1 reply; 2+ messages in thread
From: Jean Faye @ 2014-08-05 14:40 UTC (permalink / raw)
To: yocto
[-- Attachment #1: Type: text/plain, Size: 3508 bytes --]
Hi all,
I want to use syslog-ng to log the messages generated by my application implemented in C language. I added this in the code:
char *log="rtcd";
printf("[%s] RTC adjustement\n",__func__);
openlog(log, LOG_PID, LOG_LOCAL0);
syslog(LOG_DEBUG, "[FIJ] RTC adjustement");
closelog();
For me, according to the syslog-ng file, the files /var/log/ldb/GENTrace.log, /var/log/ldb/SUTrace.log, /var/log/ldb/WANTrace.log and /var/log/ldb/CPLTrace.log must be created and must contain the syslog message.
But I got no messages in my destination files. You can see the content of my syslog-ng.conf file bellow.
Is it the right way to log the messages sent by C program? What can explain that I got no messages in the destinations files?
I am using syslog-ng 3.5.4.1 provided by yocto. And in the script which run the binary (initscript file) I remove the line below:
. /etc/init.d/functions
Why are you using the line? Is it necessary to use it?
Concerning log file rotation, How can we manage it using syslog-ng? For example I want to have a destination file with a size maximum = 2Mo and if the size is greater than the max size, I have to save the current one and create a new one. On my system I can have max 4 files (4 x 2Mo). How can I manage this kind of rotation?
Thanks in advance.
Best regards,
Ismael Jean FAYE
@version: 3.5
#
# Syslog-ng configuration file, compatible with default Debian syslogd
# installation. Originally written by anonymous (I can't find his name)
# Revised, and rewrited by me (SZALAY Attila <sasa@debian.org>)
# First, set some global options.
options { chain_hostnames(off); flush_lines(0); use_dns(no); use_fqdn(no);
owner("root"); group("adm"); perm(0640); stats_freq(0);
bad_hostname("^gconfd$");create_dirs(yes);
};
########################
# Sources
########################
source s_mysource {
pipe("/tmp/pipe" pad_size(2048));
};
########################
# Destinations
########################
destination d_GEN {
file("/var/log/ldb/GENTrace.log");
};
destination d_SU {
file("/var/log/ldb/SUTrace.log");
};
destination d_WAN {
file("/var/log/ldb/WANTrace.log");
};
destination d_CPL {
file("/var/log/ldb/CPLTrace.log");
};
########################
# Filters
########################
#filter f_GEN {
#facility(local0) and filter(nom_du_composant_applicatif);
#facility(local0) and filter(f_debug);
#facility(local0);
#};
filter f_SU {
#facility(local0) and filter(nom_du_composant_applicatif);
#facility(local0) and filter(f_debug);
facility(local0);
};
filter f_WAN {
#facility(local0) and filter(nom_du_composant_applicatif);
#facility(local0) and filter(f_debug);
facility(local0);
};
filter f_CPL {
#facility(local0) and filter(nom_du_composant_applicatif);
#facility(local0) and filter(f_debug);
facility(local0);
};
########################
# Log paths
########################
#log { source(s_mysource); filter(f_GEN); destination(d_GEN); };
log { source(s_mysource); filter(f_SU); destination(d_SU); };
log { source(s_mysource); filter(f_WAN); destination(d_WAN); };
log { source(s_mysource); filter(f_CPL); destination(d_CPL); };
[-- Attachment #2: Type: text/html, Size: 7008 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Tr : Help - How to log the messages generated by c program using syslog-ng and how to manage log file rotation
2014-08-05 14:40 How to log the messages generated by c program using syslog-ng and how to manage log file rotation Jean Faye
@ 2014-08-06 9:08 ` Jean Faye
0 siblings, 0 replies; 2+ messages in thread
From: Jean Faye @ 2014-08-06 9:08 UTC (permalink / raw)
To: yocto, yocto-request
[-- Attachment #1: Type: text/plain, Size: 3527 bytes --]
Help:
Hi all,
I want to use syslog-ng to log the messages generated by my application implemented in C language. I added this in the code:
char *log="rtcd";
printf("[%s] RTC adjustement\n",__func__);
openlog(log, LOG_PID, LOG_LOCAL0);
syslog(LOG_DEBUG, "[FIJ] RTC adjustement");
closelog();
For me, according to the syslog-ng file, the files /var/log/ldb/GENTrace.log, /var/log/ldb/SUTrace.log, /var/log/ldb/WANTrace.log and /var/log/ldb/CPLTrace.log must be
created and must contain the syslog message.
But I got no messages in my destination files. You can see the content of my syslog-ng.conf file bellow.
Is it the right way to log the messages sent by C program? What can explain that I got no messages in the destinations files?
I am using syslog-ng 3.5.4.1 provided by yocto. And in the script which run the binary (initscript file) I remove the line below:
. /etc/init.d/functions
Why are you using the line? Is it necessary to use it?
Concerning log file rotation, How can we manage it using syslog-ng? For example I want to have a destination file with a size maximum = 2Mo and if the size is greater than the max size, I have to save the current one and create a new one. On my
system I can have max 4 files (4 x 2Mo). How can I manage this kind of rotation?
Thanks in advance.
Best regards,
Ismael Jean FAYE
@version: 3.5
#
# Syslog-ng configuration file, compatible with default Debian syslogd
# installation. Originally written by anonymous (I can't find his name)
# Revised, and rewrited by me (SZALAY Attila <sasa@debian.org>)
# First, set some global options.
options { chain_hostnames(off); flush_lines(0); use_dns(no); use_fqdn(no);
owner("root"); group("adm"); perm(0640); stats_freq(0);
bad_hostname("^gconfd$");create_dirs(yes);
};
########################
# Sources
########################
source s_mysource {
pipe("/tmp/pipe" pad_size(2048));
};
########################
# Destinations
########################
destination d_GEN {
file("/var/log/ldb/GENTrace.log");
};
destination d_SU {
file("/var/log/ldb/SUTrace.log");
};
destination d_WAN {
file("/var/log/ldb/WANTrace.log");
};
destination d_CPL {
file("/var/log/ldb/CPLTrace.log");
};
########################
# Filters
########################
filter f_GEN {
#facility(local0) and filter(nom_du_composant_applicatif);
#facility(local0) and filter(f_debug);
facility(local0);
};
filter f_SU {
#facility(local0) and filter(nom_du_composant_applicatif);
#facility(local0) and filter(f_debug);
facility(local0);
};
filter f_WAN {
#facility(local0) and filter(nom_du_composant_applicatif);
#facility(local0) and filter(f_debug);
facility(local0);
};
filter f_CPL {
#facility(local0) and filter(nom_du_composant_applicatif);
#facility(local0) and filter(f_debug);
facility(local0);
};
########################
# Log paths
########################
log { source(s_mysource); filter(f_GEN); destination(d_GEN); };
log { source(s_mysource); filter(f_SU);
destination(d_SU); };
log { source(s_mysource); filter(f_WAN); destination(d_WAN); };
log { source(s_mysource); filter(f_CPL); destination(d_CPL); };
[-- Attachment #2: Type: text/html, Size: 9013 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-08-06 9:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-05 14:40 How to log the messages generated by c program using syslog-ng and how to manage log file rotation Jean Faye
2014-08-06 9:08 ` Tr : Help - " Jean Faye
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.