linux syslog
来源:互联网 发布:2016年度网络热词 编辑:程序博客网 时间:2024/05/29 01:54
void openlog(const char *ident, int option, int facility);void syslog(int priority, const char *format, ...);void closelog(void);
option
LOG_CONS Write directly to system console if there is an error while sending to system logger.LOG_NDELAY Open the connection immediately (normally, the connec‐ tion is opened when the first message is logged).LOG_NOWAIT Don't wait for child processes that may have been cre‐ ated while logging the message. (The GNU C library does not create a child process, so this option has no effect on Linux.)LOG_ODELAY The converse of LOG_NDELAY; opening of the connection is delayed until syslog() is called. (This is the default, and need not be specified.)LOG_PERROR (Not in POSIX.1-2001 or POSIX.1-2008.) Print to stderr as well.LOG_PID Include PID with each message.
配置文件
# ls /etc/rsyslog.conf# ls /etc/rsyslog.d/20-ufw.conf 50-default.conf
# cat 50-default.confauth,authpriv.* /var/log/auth.log*.*;auth,authpriv.none -/var/log/syslog#cron.* /var/log/cron.log#daemon.* -/var/log/daemon.logkern.* -/var/log/kern.log#lpr.* -/var/log/lpr.logmail.* -/var/log/mail.log#user.* -/var/log/user.log#local5.* -/var/log/user.log
auth:身份认证相关
cron:进程或调度相关
daemon:守护进程相关
kern:内核相关
mail:邮件相关
user:用户自定义相关
local[0-7]:用户自定义相关格式:
facility.level
注:配置生效需要重启rsyslog
facility
LOG_AUTH security/authorization messagesLOG_AUTHPRIV security/authorization messages (private)LOG_CRON clock daemon (cron and at)LOG_DAEMON system daemons without separate facility valueLOG_FTP ftp daemonLOG_KERN kernel messages (these can't be generated from user pro‐ cesses)LOG_LOCAL0 through LOG_LOCAL7 reserved for local useLOG_LPR line printer subsystemLOG_MAIL mail subsystemLOG_NEWS USENET news subsystemLOG_SYSLOG messages generated internally by syslogd(8)LOG_USER (default) generic user-level messagesLOG_UUCP UUCP subsystem
level
LOG_EMERG system is unusableLOG_ALERT action must be taken immediatelyLOG_CRIT critical conditionsLOG_ERR error conditionsLOG_WARNING warning conditionsLOG_NOTICE normal, but significant, conditionLOG_INFO informational messageLOG_DEBUG debug-level message
emerg:紧急
alert:报警
crit:关键
err:错误
warning:警告
notice:通知
info:消息
debug:调试
举例
local5.* -/var/log/user.logopenlog("hello furong.", LOG_CONS | LOG_PID | LOG_PERROR, LOG_LOCAL5);FILE *f = fopen("hello", "r"); syslog(LOG_ERR, "oops - %m\n"); closelog();
# tail -n1 /var/log/user.loghello furong.[5317]: oops - No such file or directory
1 0
- linux syslog
- Syslog Linux
- linux syslog
- 配置linux syslog服务器+配置syslog客户端
- linux下syslog使用说明
- linux下syslog使用说明
- [linux]syslog使用
- linux syslog转发
- linux syslog编程
- Linux syslog日志服务器
- 利用Linux syslog写日记
- Linux的syslog详解
- Linux syslog详解
- 利用Linux syslog写日记
- linux syslog日志服务
- Linux syslog服务
- linux syslog日志服务
- linux syslog自定义日志
- 移动app如何进行自动化和探索性测试
- PSVR开发小结
- GCD使用三部曲之:基本用法
- 排序算法-09-排序1 排序 (25分)-第一部分
- Edraw Office Viewer component教程(三):将MS Word、Excel、PowerPoint嵌入到WPF应用程序中
- linux syslog
- 基于神经网络的智能RC小车(Python+OpenCV)
- C#Label、CheckBox等背景色设为透明
- text-dependent speech emotion recognition 相关文献
- SQL Server 数据库IN子句和EXISTS子句转换
- HBase学习总结:HBase的工作原理
- eclipse项目导入IntelliJ IDEA :Error:(1, 1) java: 非法字符: '\ufeff'
- Promise对象的基本使用
- KMP算法