rsyslog mysql下载_Linux: Rsyslog

记录日志到Rsyslog

首先启用UDP或者TCP

#### MODULES ####

# The imjournal module bellow is now used as a message source instead of imuxsock.

$ModLoad imuxsock # provides support for local system logging (e.g. via logger command)

$ModLoad imjournal # provides access to the systemd journal

#$ModLoad imklog # reads kernel messages (the same are read from journald)

#$ModLoad immark # provides --MARK-- message capability

# Provides UDP syslog reception

#$ModLoad imudp

#$UDPServerRun 514

# Provides TCP syslog reception

#$ModLoad imtcp

#$InputTCPServerRun 514

然后使用logger命令记录日志

[root@centos ~]# logger -h

Usage:

logger [options] [message]

Options:

-T, --tcp use TCP only

-d, --udp use UDP only

-i, --id log the process ID too

-f, --file log the contents of this file

-h, --help display this help text and exit

-S, --size maximum size for a single message (default 1024)

-n, --server write to this remote syslog server

-P, --port use this port for UDP or TCP connection

-p, --priority mark given message with this priority

-s, --stderr output message to standard error as well

-t, --tag mark every line with this tag

-u, --socket write to this Unix socket

-V, --version output version information and exit

[root@centos ~]# logger -i this is message

[root@centos ~]# tail -f /var/log/messages

Jul 19 04:38:27 centos chronyd[851]: System clock was stepped by 1.626715 seconds

Jul 19 04:38:27 centos systemd: Time has been changed

Jul 19 04:38:28 centos chronyd[851]: Source 162.159.200.123 replaced with 5.79.108.34

Jul 19 04:40:01 centos systemd: Started Session 2 of user root.

Jul 19 04:50:01 centos systemd: Started Session 3 of user root.

Jul 19 04:51:55 centos root: hahah

Jul 19 04:52:46 centos root[2216]: hahah

Jul 19 04:53:15 centos root[2218]: this is message

你可能感兴趣的:(rsyslog,mysql下载)