debian7, debian8's syslog config, open all log level
发布日期:2021-06-30 22:16:59 浏览次数:2 分类:技术文章

本文共 3476 字,大约阅读时间需要 11 分钟。

前言

在测试环境下(debian7 or debian8)中,发现写好的程序中,日志打印级别为INFO的日志能打印出来,警告和错误级别打不出来。 这时,要去将源码中所有日志都改成INFO级别,那就和测试环境中的测试程序不一样了。最好是将debian的syslog日志级别全部打开。

以前也尝试配制过syslog, 没搞懂。

今天尝试成功了,可以用tail -f /var/log/messages,看到所有级别的错误日志 :)

实验

实验步骤

  • cp /etc/rsyslog.conf /etc/rsyslog.conf.bk
  • modify /etc/rsyslog.conf
  • service rsyslog restart

/etc/rsyslog.conf的修改

修改点

第91行,将所有日志级别都加上,就可以在/var/log/messages中看到所有syslog级别的日志了.

就修改这句:

*.=debug;*.=info;*.=notice;*.=warn;*.=err;*.crit;*.=alert;*.=emerg;\
## Some "catch-all" log files.#*.=debug;\    auth,authpriv.none;\    news.none;mail.none -/var/log/debug*.=debug;*.=info;*.=notice;*.=warn;*.=err;*.crit;*.=alert;*.=emerg;\    auth,authpriv.none;\    cron,daemon.none;\    mail,news.none      -/var/log/messages

完整的配置文件备份

#  /etc/rsyslog.conf    Configuration file for rsyslog.##           For more information see#           /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html##################### MODULES #####################$ModLoad imuxsock # provides support for local system logging$ModLoad imklog   # provides kernel logging support#$ModLoad immark  # provides --MARK-- message capability# provides UDP syslog reception#$ModLoad imudp#$UDPServerRun 514# provides TCP syslog reception#$ModLoad imtcp#$InputTCPServerRun 514############################### GLOBAL DIRECTIVES ################################# Use traditional timestamp format.# To enable high precision timestamps, comment out the following line.#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat## Set the default permissions for all log files.#$FileOwner root$FileGroup adm$FileCreateMode 0640$DirCreateMode 0755$Umask 0022## Where to place spool and state files#$WorkDirectory /var/spool/rsyslog## Include all config files in /etc/rsyslog.d/#$IncludeConfig /etc/rsyslog.d/*.conf################### RULES ##################### First some standard log files.  Log by facility.#auth,authpriv.*         /var/log/auth.log*.*;auth,authpriv.none      -/var/log/syslog#cron.*             /var/log/cron.logdaemon.*            -/var/log/daemon.logkern.*              -/var/log/kern.loglpr.*               -/var/log/lpr.logmail.*              -/var/log/mail.loguser.*              -/var/log/user.log## Logging for the mail system.  Split it up so that# it is easy to write scripts to parse these files.#mail.info           -/var/log/mail.infomail.warn           -/var/log/mail.warnmail.err            /var/log/mail.err## Logging for INN news system.#news.crit           /var/log/news/news.critnews.err            /var/log/news/news.errnews.notice         -/var/log/news/news.notice## Some "catch-all" log files.#*.=debug;\    auth,authpriv.none;\    news.none;mail.none -/var/log/debug*.=debug;*.=info;*.=notice;*.=warn;*.=err;*.crit;*.=alert;*.=emerg;\    auth,authpriv.none;\    cron,daemon.none;\    mail,news.none      -/var/log/messages## Emergencies are sent to everybody logged in.#*.emerg             :omusrmsg:*## I like to have messages displayed on the console, but only on a virtual# console I usually leave idle.##daemon,mail.*;\#   news.=crit;news.=err;news.=notice;\#   *.=debug;*.=info;\#   *.=notice;*.=warn   /dev/tty8# The named pipe /dev/xconsole is for the `xconsole' utility.  To use it,# you must invoke `xconsole' with the `-file' option:# #    $ xconsole -file /dev/xconsole [...]## NOTE: adjust the list below, or you'll go crazy if you have a reasonably#      busy site..#daemon.*;mail.*;\    news.err;\    *.=debug;*.=info;\    *.=notice;*.=warn   |/dev/xconsole

转载地址:https://lostspeed.blog.csdn.net/article/details/79278184 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:delete and delete[] on oop
下一篇:debug : CoInitialize执行的时机

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年05月05日 02时39分22秒