Centralized logging with syslog

จดบันทึกโดยการอ้างอิจแบบสั้นๆ เข้าใจง่ายดี สำหรับขั้นตอนการติดตั้งและนำมาใช้งาน Centralized Log Server | PHP-Syslog-NG | Syslog-ng-SSH log

####################################
# SYSLOG NOTES BY Mark E. Donaldson
####################################
# SYSLOG STARTUP OPTIONS
####################################

-r flag used to accept messages from remote machines
-h flag allows syslog to send messages to a remote machine

#############################
# SYSLOG.CONF FILE
#############################
Syntax: selector <TAB> action
selector = facility.level
action = where to log

Facilities (Programs):
● kern
● user (default)
● mail
● daemon
● auth
● lpr
● news
● uucp
● cron
● mark
● local0-7
● syslog
● authpriv
● ftp
● * (all or any) & none

Levels (Severity):
● emerg
● alert
● crit
● err
● warning
● notice
● info
● debug
● * (all or any) & none

Actions:
● filename
● @hostname
● @ipaddress
● user1
● *
● – symbol in front of file means synchronization & buffering

Examples:
# Enable remote logging
*.* @192.168.0.3
*.* @server4.bandwidthco.com

# enable this, if you want that root is informed
*.alert root

# all email-messages in one file
mail.* /var/log/mail

# email in separate files
mail.info /var/log/mail.info
mail.warn /var/log/mail.warn
mail.err /var/log/mail.err
# Warnings in one file
*.=warn;*.=err /var/log/warn
*.crit /var/log/warn
# save the rest in one file
*.*;mail.none;news.none /var/log/messages
*.* /var/log/allmessages

###########################
# LOGGER COMMAND
###########################
Syntax: logger –p facility.level –t tag message | file filename

-p option = facility and severity level
-t option = identifying tag in message
-I option = include process ID in message

Example:
logger –I –p local1.err –t FFT “Job Failed – scratch disk full”
##########################################
# Syslog Notes By Peter Matulis [email protected]
##########################################
Facilities:
Numerical Code Keyword Facility
0 kern Kernel
1 user Regular user processess
2 mail Mail system
3 daemon System daemons
4 auth Security (authentication and authorisation) related commands
5 syslog Syslog internal messages
6 lpr Line printers system
7 news NNTP subsystem
8 uucp UUCP subsystem
10 authpriv Private authorisation messages
16-23 local0-7 Site specific use

Priorities:
Numerical Code Keyword Facility
0 emerg Emergency: system is unusable
1 alert Alert: action must be taken immediately
2 crit Critical: critical conditions
3 err Error: error conditions
4 warning Warning: warning conditions
5 notice Notice: normal but significant conditions
6 info Informational: informational messages
7 debug Debug: debug level messages

Note : Numerical codes should not be used in syslog.conf on Linux systems. Should you need to configure a non-Linux syslog deamon which uses numerical codes only
e.g. Cisco Router, to send syslog messages to your log server.

Logging software:
The rsyslog tool was chosen over the more popular syslog-ng for the following reasons:

1. Licensing and software features
Syslog-ng is dual-licensed. A commercial product has been forked from the open-
source (GPL) project and the more advanced features are found only in the
commercial offering. Affected features of import so far are i) native TLS/SSL support
(i.e. not using stunnel) and ii) on-disk spooling of messages. It’s unknown how these
forks will diverge in the future.

2. Truly reliable message delivery (RELP)
Rsyslog is confronting the unreliability of TCP in a logging environment through the
development of the RELP protocol whereas syslog-ng is not.

3. Compliance with IETF regarding reliable TCP transport (RFC 3195)
Rsyslog is compliant with the standards regarding reliable TCP transport whereas
syslog-ng is not.

4. Native support for traffic encryption (TLS/SSL)
Rsyslog supports TLS natively whereas the GPL fork of syslog-ng does not.

5. SNMP support
Rsyslog supports SNMP traps whereas syslog-ng does not.

6. BSD-style hostname and program name blocks
Rsyslog supports powerful BSD-style hostname and program name blocks for easy
multi-host implementations whereas syslog-ng does not.

7. On-disk message spooling
Rsyslog has on-disk file spooling features that are lacking in GPL syslog-ng:
● on-demand (as needed) spooling
● independent spool files per log action
● spool files on multiple disks
● Process spooled messages during configured timeframes

8. Include config files
Rsyslog has configuration include file support that syslog-ng lacks. This allows one to
organize and split one’s configuration into multiple files.

9. Native support for email alerts
Rsyslog natively supports the ability to send email alerts based on log message
content. Syslog-ng needs to pipe data to an external process.

Logging models:

1. Single system (to disk)
Individual computer systems, by default, perform logging. Messages typically get written to the
local hard drive but Network Attached Storage (NAS) or Storage Area Network (SAN) are also
valid storage options for this model.

Single system (to disk)
Single system (to disk)

2. Multiple systems (to disk)
Known as central logging, many systems forward their logs over the network to a central logging
server. Analogous to the single-system model, on the server-side, messages get written to the
local hard drive or to some other available storage.

Multiple systems (to disk)
Multiple systems (to disk)

3. Multiple systems (to database)
A common option is to have the remote messages stored directly into a database on the server
with, possibly, a web-based interface acting as a viewing/query tool.
The database need not reside on the logging server (as shown in the diagram); it can be placed
onto a separate system.

Multiple systems (to database)
Multiple systems (to database)