分类: LINUX
2008-03-03 21:33:30
A destination is where a log message is sent if the filtering rules match. Similarly to sources, destinations consist of one or more drivers, each defining where and how messages are sent.
# 注释 :一个 destination 是指一个消息一旦匹配过滤器规则后,会被发送到那里。和 sources 一样,destinations 也是由多个 drivers 组成的,每个都定义了日志被发送到那里。
Tip | |
---|---|
If no drivers are defined for a destination, all messages sent to the destination are discarded. This is equivalent to omitting the destination from the log statement. # 注释 :如果一个 destination 没有定义 destination driver ,则所有送到该 destination 的消息会被丢弃。 |
To define a destination, add a destination statement to the syslog-ng configuration file using the following syntax:
# 注释 :下面是 destination 的定义格式 :
destination{
destination-driver(params); destination-driver(params); ... };
Example 3.5. A simple destination statement | |
---|---|
The following destination statement sends messages to the TCP port # 注释 :下面定义了一个 destination ,名为 d_demo_tcp ,有一个 driver ,位置是 10.1.2.3:1999 destination d_demo_tcp { tcp("10.1.2.3" port(1999)); }; If name resolution is configured, the hostname of the target server can be used as well. # 注释 :还可以使用主机名。 destination d_tcp { tcp("target_host" port(1999); localport(999)); }; |
The following table lists the destination drivers available in syslog-ng.
# 注释 :destination driver 有自己的 driver ,且和 source drivers 不同
# -)1、file() :写日志到指定文件
# -)2、fifo()、pipe():写日志到指定命名管道
# -)3、unix-stream() :发送消息到指定的 SOCK_STREAM 型 socket
# -)4、unix-dgram():发送消息到指定的 SOCK_DGRAM 型 socket
# -)5、tcp():发送消息到指定的远程主机的 TCP 端口
# -)6、udp():同上,但改为 UDP 端口
# -)7、tcp6()、udp6()
# -)8、usertty() :发送到用户的 tty ,如果该用户已经登录的话
# -)9、program():启动指定的程序,并把消息作为输入
# -)19、sql() :发送到一个 SQL 数据库
Name | Description |
---|---|
Writes messages to the specified file. | |
Writes messages to the specified named pipe. | |
Sends messages to the specified
unix socket in SOCK_STREAM style
(Linux). | |
Sends messages to the specified
unix socket in SOCK_DGRAM style
(BSD). | |
Sends messages to the specified TCP port of a remote host. | |
Sends messages to the specified UDP port of a remote host. | |
Sends messages to the specified TCP port of a remote host using IPv6. | |
Sends messages to the specified UDP port of a remote host using IPv6. | |
Sends messages to the terminal of the specified user, if the user is logged in. | |
Forks and launches the specified program, and sends messages to its standard input. | |
Sends messages into an SQL database. |
Table 3.4. Destination drivers available in syslog-ng
For detailed description of the supported drivers, see .
Note | |
---|---|
When using the # 注释 :注意,如果使用的是 file()类型的 destination driver ,则必须使用 log rotate 辅助,否则日志会变得非常打。 |