设为首页 收藏本站
查看: 604|回复: 0

[经验分享] centos7 syslog

[复制链接]
发表于 2018-4-20 09:16:41 | 显示全部楼层 |阅读模式
  安装脚本如下

无法启动错误或由syslog-ng.conf配置原因
正确配置如下

@version: 3.8
#Default configuration file for syslog-ng.
#For a description of syslog-ng configuration file directives, please read
the syslog-ng Administrator's guide at:
#http://www.balabit.com/dl/html/syslog-ng-admin-guide_en.html/bk01-toc.html
Modify with QuWenQing
POWER BY PSIONIC---SECTION-[aurora] BEGIN
DATE: 2017-04-06.16:21
Modify with QuWenQing
@module syslogformat
@module afsocket
@module affile
@module afprog
@module afsmtp
@module afuser
@module system-source
@module basicfuncs
@module cryptofuncs
@module dbparser
@define autoload-compiled-modules 1
options {
log_msg_size(16384);
flush_lines(1);
log_fifo_size(1000000);
time_reopen(10);
use_dns(no);
dns_cache(yes);
use_fqdn(yes);
keep_hostname(yes);
chain_hostnames(no);
check_hostname(yes);
create_dirs(yes);
dir_perm(0755);
perm(0644);
stats_freq(1800);
threaded(yes);
};
include "include/*.cnf";
source s_local {
# standard Linux log source (this is the default place for the syslog()
# function to send logs to)
unix-stream("/dev/log" max-connections(10240) log_iw_size(1024000));
#messages from the kernel
file("/proc/kmsg" program_override("kernel"));
};
filter f_messages { level(info..emerg) and not facility(mail,authpriv,cron,local3,local4,local5,local6) and not program("snmpd"); };
filter f_secure { facility(authpriv); };
filter f_mail { facility(mail); };
filter f_cron { facility(cron); };
filter f_emerg { level(emerg); };
filter f_spooler { level(crit..emerg) and facility(uucp, news); };
filter f_local7 { facility(local7); };
filter f_snmpd { program("snmpd"); };
destination d_messages { file("/var/log/messages"); };
destination d_secure { file("/var/log/secure"); };
destination d_maillog { file("/var/log/maillog"); };
destination d_cron { file("/var/log/cron"); };
destination d_console { usertty("root"); };
destination d_spooler { file("/var/log/spooler"); };
destination d_bootlog { file("/var/log/dmesg"); };
destination d_snmpd { file("/var/log/snmpd/snmpd.$YEAR$MONTH" create_dirs(yes)); };
log { source(s_local); filter(f_secure); destination(d_secure); flags(final);};
log { source(s_local); filter(f_mail); destination(d_maillog); flags(final);};
log { source(s_local); filter(f_cron); destination(d_cron); flags(final);};
log { source(s_local); filter(f_snmpd); destination(d_snmpd); flags(final);};
log { source(s_local); filter(f_emerg); destination(d_console); };
log { source(s_local); filter(f_spooler); destination(d_spooler); };
log { source(s_local); filter(f_local7); destination(d_bootlog); };
log { source(s_local); filter(f_messages); destination(d_messages); };
#POWER BY PSIONIC---SECTION-[aurora] END
#POWER BY PSIONIC---SECTION-[gsys-lognode] BEGIN
#project logs
include "include/*.pre";
destination d_remote_back_all {file("/data/projlogs/$PROGRAM/$YEAR$MONTH/$DAY/$HOUR.$HOST" perm(0644) dir_perm(0755) create_dirs(yes) template("${MONTH_ABBREV} $DAY ${HOUR}:${MIN}:${SEC} ${HOST} ${PROGRAM}[${PID}]: ${MSG}\n") template-escape(no));};
filter f_remote_log_all {facility(local6) and match("/" value("PROGRAM"));};
log {source(s_local);filter(f_remote_log_all);destination(d_remote_back_all);flags(final);};
#nginx logs
template nginx_format { template("$PROGRAM $MSG\n"); template_escape(no); };
parser nginx { db_parser(file("/usr/local/syslog-ng/etc/patterndb.d/nginx.xml")); };
source s_nginx_access {
pipe("/usr/local/nginx/logs/access_log");
};
destination d_nginx_access {file("/usr/local/nginx/logs/${N.vhost}/$YEAR$MONTH/$DAY/access_$HOUR.log" perm(0644) dir_perm(0755) create_dirs(yes) template(nginx_format));};
log {source(s_nginx_access);parser(nginx);destination(d_nginx_access);flags(final);};
source s_nginx_error {
pipe("/usr/local/nginx/logs/error_log");
};
destination p_nginx_error {file("/usr/local/nginx/logs/${N.vhost}/$YEAR$MONTH/$DAY/error_$HOUR.log" perm(0644) dir_perm(0755) create_dirs(yes) template(nginx_format));};
destination d_nginx_error {file("/usr/local/nginx/logs/$YEAR$MONTH/$DAY/error_$HOUR.log" perm(0644) dir_perm(0755) create_dirs(yes) template(nginx_format));};
log {source(s_nginx_error);parser(nginx);destination(p_nginx_error);destination(d_nginx_error);flags(final);};
#php-fpm logs
template php-fpm_format { template("$PROGRAM $MSG\n"); template_escape(no); };
source s_php-fpm {
pipe("/data/phplogs/phpfpm_slow.log");
};
destination d_php-fpm {file("/data/phplogs/$YEAR$MONTH/$DAY/phpfpm_slow.$HOUR.log" perm(0644) dir_perm(0755) create_dirs(yes) template(php-fpm_format));};
log {source(s_php-fpm);destination(d_php-fpm);flags(final);};
include "include/*.conf";
#POWER BY PSIONIC---SECTION-[gsys-lognode] END
  启动后查看状态报错Error stating pattern database file, no automatic reload will be performed; error='No such file or directory'
  这个需要在/usr/local/syslog-ng/etc/patterndb.d下放置两个文件
链接:https://pan.baidu.com/s/1nv010qH 密码:6zl3
然后重启就好

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-449437-1-1.html 上篇帖子: Centos7.4 安装 Inception 下篇帖子: CentOS 6.9自建开源镜像站
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表