วันเสาร์ที่ 23 สิงหาคม พ.ศ. 2557

การส่ง Apache access log ไปยัง Syslog server

ระบบที่ใช้ทดสอบ : Ubuntu server 14.04, Apache2

แก้ไขไฟล์ /etc/apache2/sites-available/000-default.conf (ทั้งนี้ขึ้นอยู่กับว่าใช้ vHost ชื่ออะไร)
โดยเพิ่ม

ErrorLog syslog:local6
CustomLog "||/usr/bin/logger -t apache -i -p local6.notice" combined

จากนั้นแก้ไขไฟล์  /etc/rsyslog.d/50-default.conf
โดยเพิ่ม 
*.*             @192.168.38.142

จากนั้นทำการ restart rsyslog และ apache2 ดังนี้

service rsyslog restart
และ
service apache2 restart


ref. https://raymii.org/s/snippets/Apache_access_and_error_log_to_syslog.html