Chinaunix首页 | 论坛 | 博客
  • 博客访问: 983911
  • 博文数量: 186
  • 博客积分: 10020
  • 博客等级: 上将
  • 技术积分: 1676
  • 用 户 组: 普通用户
  • 注册时间: 2006-08-14 17:08
文章存档

2011年(5)

2009年(11)

2008年(2)

2007年(111)

2006年(57)

我的朋友

分类: LINUX

2006-11-16 13:15:59

 
openlog():opens a connection to the system logger for a program
syslog():generates a log message, which will be distributed  by  syslogd(8).
 

LOG_PID:Include PID with each message.
LOG_CONS:Write directly to system console if there is an error while sending to system logger.
LOG_ERR:error conditions
LOG_LOCAL0 through LOG_LOCAL7:reserved for local use
 
#include
int main()
{
 int test = 10;
 
 openlog("MySysLogTest", LOG_PID|LOG_CONS, LOG_LOCAL7);
 
 syslog(LOG_LOCAL7|LOG_ERR, "ERROR: just my test error msg syslog(test val=%d)\n", test);
 closelog();
 return 0;
}
 
这个小程序执行完后
/var/log/boot.log:Nov 16 11:18:08 localhost MySysLogTest[2804]: ERROR: just my test error msg syslog(test val=10)
/var/log/messages:Nov 16 11:18:08 localhost MySysLogTest[2804]: ERROR: just my test error msg syslog(test val=10)
阅读(5676) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~