syslog to write in system log file.
find log config at following place as per your systems
1./etc/logrotate.d/
2./etc/logrotate.conf
3. /etc/syslog.com
Log stored at following locations.
/var/log/syslog
message managed by syslogd daemon.
passed on socket /dev/log.
#include <syslog.h>
don't delete first parameter of openlog.
always makesure before deleted or out of scope of first parameter use closelog call.
void write2syslog(const std::string & str)
{
setlogmask (LOG_UPTO (LOG_NOTICE));
openlog ("mydaemon", LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1);
//syslog (LOG_NOTICE, "Program started by User %d", getuid ());
syslog (LOG_INFO, str.c_str());
closelog ();
}
No comments:
Post a Comment
would you like it. :)