syslog 사용과 syslog.conf 파일에 대한 질문입니다. 꼭 봐주세

black0328의 이미지

log 를 남기기 위해 syslog 함수를 사용하려고 합니다.

/var/log/message 와 같은 디폴트 파일에 로그를 쌓는게 아니라 제가 임의로 정한 파일 /var/log/message_test 에 로그를 쌓고 싶습니다

또 syslog.conf 파일에서

First some standard logfiles.  Log by facility.
#

auth,authpriv.*                 /var/log/auth.log
*.*;auth,authpriv.none          -/var/log/syslog
#cron.*                         /var/log/cron.log
daemon.*                        -/var/log/daemon.log
kern.*                          -/var/log/kern.log
lpr.*                           -/var/log/lpr.log
mail.*                          -/var/log/mail.log
user.*                          -/var/log/user.log
uucp.*                          /var/log/uucp.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.info
mail.warn                       -/var/log/mail.warn
mail.err                        /var/log/mail.err

# Logging for INN news system
#
news.crit                       /var/log/news/news.crit
news.err                        /var/log/news/news.err
news.notice                     -/var/log/news/news.notice

#
# Some `catch-all' logfiles.
#
*.=debug;\
        auth,authpriv.none;\
        news.none;mail.none     -/var/log/debug
*.=info;*.=notice;*.=warn;\
        auth,authpriv.none;\
        cron,daemon.none;\
        mail,news.none          -/var/log/messages

#
# Emergencies are sent to everybody logged in.
#
*.emerg                         *

#
# 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.crit;news.err;news.notice;\
        *.=debug;*.=info;\
        *.=notice;*.=warn       |/dev/xconsole

특정 daemon,mail,news 와같은 것이 아닌 제가 만든 데몬(test_daemon)의 로그를 쌓고 싶습니다

예제) test_daemon.* /var/log/message_test

실제로 /var/log/message_test 에 로그를 쌓고 싶습니다.

지금 제가 처한 문제점은

첫째 syslog.conf 파일을 어떻게 변경해야하는지를 모르겟습니다.

둘째 위와 같은 경우에 syslog() 함수를 어떻게 써야할 지 감이 잡히지 않습니다.

방법을 아신다면 제게 알려주세요

progcom의 이미지

syslogd.conf에서 설정은 syslog()의 priority인자에 대응합니다.

 void
     syslog(int priority, const char *message, ...);

상수는 man페이지에 나와있으니 열어보시고, 간단한 예제를 들자면,

syslog(LOG_INFO|LOG_KERN, "ERRMSG");

이렇게 지정하면 syslogd.conf에서의 kern.info에 대응하게 됩니다.
(*.info나 kern.*에도 대응하겠지요)