post by yamamoto | 0 | 1,014 views

プログラムで 自作 log を作成する

  • syslog-ng の設定

# watch
source s_src { file ("/proc/kmsg" program_override("kernel: ")); unix-stream("/dev/log"); system(); internal(); };

destination df_watch { file("/var/log/watch.log"); };
filter f_watch { facility(local0); };
log { source(s_all); filter(f_watch); destination(df_watch); };

  • logger コマンドでログを作る

logger -p local0.notice -i -t "Hello!" "Good morning !!!"

  • /etc/logrotate.d/watch

/var/log/watch.log {
    rotate 60
    monthly
    compress
    endscript
}

 

 

Comments are closed.