#------------------------------------------------------------------- # syslog-ng Configuration for Cygwin # FILE : /etc/syslog-ng/syslog-ng.conf # CREATOR NAME : k-square # http://www.yotta-zetta.com/k-square/ # HISTORY : 2002/xx/xx Create # 2002/10/13 Update # 2003/07/28 Update #------------------------------------------------------------------- ####################################################################### ## 全体に適用する設定 ####################################################################### options { ## 受け取り次第書き込む sync(0); ## ある程度貯めてたまってから送付 # log_fifo_size(2000); ## TCPコネクションを定期的に張りなおす(たぶん) # time_reopen(10); ## ある一定間隔を空けないとログを受け付けない設定 ## ログのオーバーフロー攻撃を防ぐためのものと思われる(たぶん) ## Ferme un fichier de journalisation non accede apres N secondes (仏語説明) # time_reap(number); ## なんらかの処理の時間間隔を設定する(たぶん) でも動いてないのかも? ## man コマンドでも出てくるから多分実装されてるんじゃないかと思うけど、 ## まだ動かないとかいてあるものも見るのでどちらか分からない。 ## set mark frequency to n seconds (原文) ## Nombre de secondes entre 2 --MARK-- -non encore disponible- (仏語説明) mark(600); ## 送信元Hostを長い形式で記述するかどうか (yes|no) long_hostnames(no); ## 送信元HostについてDNSで名前を引くかどうか (yes|no) use_dns(no); ## 送信元HostについてFQDNで記録するかどうか (yes|no) use_fqdn(no); ## 転送されたSyslogについて送信元のホスト名をつけるようにする。 ## A → B の転送をしているとすると ## Aの内部ログを転送したときに受信されたLogは、Bの内部ログのように ## ログに保存されてしまうのを防ぐ (yes|no) keep_hostname(yes); ## 指定している保存先のディレクトリが無かったらディレクトリを作成する create_dirs(yes); ## 所有者とパーミッションの設定 IDでの指定はできない owner(SYSTEM); group(admins); dir_perm(0750); perm(0640); ## Syslogの送信元の時刻が合ってないときはこのオプションで ## Syslogdの受信時刻をSyslogに記録する時刻とする (yes|no) use_time_recvd(no); ## 以下のオプション群はまだ実装されていないらしい ## Le "garbage collector" est lance au bout ## de 100 evenements si syslog-ng est inactif. (仏語説明) # gc_idle_threshold(100); ## Le garbage collector est lance au bout de ## 3000 evenement si syslog-ng est actif. (仏語説明) # gc_busy_threshold(3000); ## -non encore disponible- (仏語説明) # encrypt; ## Compresse les fichiers de sortie en utilisant la Zlib ## -non encore disponible- (仏語説明) # compress; ## -non encore disponible- (仏語説明) # authentication; }; ####################################################################### ## 以下がログの設定 ####################################################################### ## CYGWINの場合は option で設定しようとここで設定しようと ## ファイルパーミッションがうまく働かない ## ディレクトリの所有者 & パーミッションも正しく設定されないみたい source src_net { udp(ip(0.0.0.0) port(514)); tcp(ip(0.0.0.0) port(514) keep-alive(yes)); }; destination dest_facility { file("/var/log/syslog-ng/$YEAR$MONTH$FACILITY.log" dir_perm(0770) perm(0660)); }; log { source(src_net); destination(dest_facility); }; ####################################################################### # Following Setting Examples are collected by k-square ####################################################################### # ## Global Options #options { mark(600); sync(0); use_dns(yes); create_dirs(yes); }; # ## Source dirvers #source src_int { internal(); }; #source src { pipe("/proc/kmsg"); unix-stream("/dev/log"); }; # ## Destinations drivers; use macro expansion to make seperating logs easier #destination d_facility { file("/var/log/syslog-ng/$HOST/$YEAR/$MONTH/$DAY/$FACILITY" perm(0600)); }; #destination d_program { file("/var/log/syslog-ng/$HOST/$YEAR/$MONTH/$DAY/$PROGRAM" perm(0600)); }; # ## Filters #filter f_fw { match(ACCEPT) or match(REJECT) or match(DENY); }; #filter f_not_fw { not match(REJECT); }; # ## Finally, actually log everything to its appropriate place #log { source("src"); destination("d_facility"); }; #log { source("src"); destination("d_program"); }; # ## Log all firewall matches to a seperate log #destination d_fw { file("/var/log/syslog-ng/firewall.log" perm(0600)); }; #log { source("src"); filter("f_fw"); destination("d_fw"); }; # ## Log all internal() stuff to seperate log #destination d_int { file("/var/log/syslog-ng/internal.log" perm(0600)); }; #log { source("src_int"); destination("d_int"); }; # ## Log everything to a seperate log #destination d_all { file("/var/log/syslog-ng/syslog-ng" perm(0600)); }; #log { source("src_int"); source("src"); filter("f_not_fw"); destination("d_all"); }; # ## log everything remote/local to a console tty #destination d_tty { file("/dev/tty11"); }; #log { source("src"); source("src_int"); destination("d_tty"); }; ####################################################################### # メールを送信するための手法 ####################################################################### # # ############################################################### # # contents of /usr/local/bin/syslog-mail # # # # #!/bin/sh # # while read line; do # # echo $line | /usr/bin/mail -s "log alert" nate@campin.net # # done # ############################################################### # # # send alerts via mail # destination mail-alert { program("/usr/local/bin/syslog-mail"); }; ####################################################################### # man syslog 抜粋 ####################################################################### # facility は 次 の キ ー ワ ー ド のいずれかである: auth、 # authpriv、 cron、 daemon、 kern、 lpr、 mail、 mark、 # news、 security (auth と 同じ)、 syslog、 user、 uucp、 # local0からlocal7。このうち security は今後は利用するべきで # なく、また、 mark は内部利用のためのものなので、アプリケー # ションレベルで用いるべきではない。ただし利用できないわけで ####################################################################### # Log Format Macros List # http://lists.balabit.hu/pipermail/syslog-ng/2001-January/001153.html ####################################################################### # > Hi, # > # > syslog-ng 1.5.3 released which adds support for user # > definable log file # > formats. Here's how to use it: # > # > destination my_file { # > file("/var/log/messages" template("$ISODATE $TAG # > $FULLHOST $MESSAGE")); # > }; # > # > Documentation is not updated, for a list of available macros check out # > affile.c, expand_macros() function. I'd appreciate some # > testing, because I # > won't have too much time to do it myself. # # Here's a list of the macros and an example of their output, in the following # format # # $MACRO_NAME # description/type # example # # # $FACILITY # syslog facility name # daemon # # $PRIORITY # the syslog priority name # debug # # $LEVEL ; same output as $PRIORITY # # $TAG # Hex representaiton of the 32-bit priority/facility pair (see # /usr/include/sys/syslog.h) # 1f # # (1f is the output for "daemon/debug" as above) # # $DATE # The local system time # Jan 19 23:27:21 # # $FULLDATE # Same as $DATE but with %Y appended, # 2001 Jan 19 23:27:21 # # $ISODATE # ISO-standard format date (strftime format "%Y-%m-%dT%H:%M:%S%z") # 2001-01-19T23:27:21+1000 # # $YEAR # 4-digit year string # 2001 # # $MONTH # 2-digit month string # 01 # # $DAY # 2-digit day string # 19 # # $HOUR # 2-digit hour string # 23 # # $MIN # 2-digit minutes string # 27 # # $SEC # 2-digit seconds string # 21 # # $HOST # host string; not sure how to decode this function, in my example it's the # same as fullhost (?) # avrio # # $FULLHOST # "full hostname" (msg->host->data) # avrio # # $PROGRAM # If syslog-ng has pulled a 'program name' out of the message, this will # return that # qpage # # $MSG || $MESSAGE # The full syslog message # qpage[9366]: processing the page queue # # Balazs forgot one thing - you'll also need to include a "\n" at the end of # your template directive if you want to make your output readable :) # # e.g. # # destination my_file { # file("/var/log/messages" template("$ISODATE $TAG $FULLHOST # $MESSAGE\n")); # }; # # Balazs, my test config was: # # destination d_format_test { file("/var/log/test" template("$FACILITY # $PRIORITY $LEVEL $TAG $DATE $FULLDATE $ISODATE $YEAR $MONTH $DAY $HOUR $MIN # $SEC $HOST $FULLHOST $PROGRAM $MSG\n")); }; # # log { source(s_sys); filter(DEFAULT); destination(d_format_test); }; # # the output used in the examples above is # # daemon debug debug 1f Jan 19 23:27:21 2001 Jan 19 23:27:21 # 2001-01-19T23:27:21+1000 2001 01 19 23 27 21 avrio avrio qpage qpage[9366]: # processing the page queue # # seems to work okay with the \n. # # Thanks Balazs, now I can use the clock on my ciscos for the log messages, # again! # # -afort