/system/logging/action
action
Actions that store or send the messages selected by the rules in /system/logging. The default actions are memory (the buffer /log shows), disk (files named log), echo (open terminal sessions) and remote (a syslog...
system/logging/action
Type: Directory
存储或发送由 /system/logging 中的规则选择的消息的动作。默认动作为 memory(/log 显示的缓冲区)、disk(名为 log 的文件)、echo(打开的终端会话)和 remote(syslog 服务器,未设置地址)。每个内存动作保留自己的缓冲区,clear 会清空它。参见 日志。
| 标志 | 名称 | 描述 |
|---|---|---|
* | default | 默认动作之一:memory、disk、echo 和 remote。 |
Y | managed |
| 参数 | 类型 | 描述 |
|---|---|---|
name * | string | 动作名称,仅限字母和数字。规则通过此名称引用该动作;对于 target=memory,它也是 /log 的 buffer 字段中显示的缓冲区名称。 |
target * | enum (memory | disk | echo | remote | email | script | cmr) { memory:0, disk:1, echo:2, remote:3, email:4, script:5, cmr:6 } | 消息的去向: - memory - 保留在以动作命名的内存缓冲区中,由 /log/print 显示。重启后缓冲区为空。 - disk - 写入文本文件(disk-file-name)。 - echo - 在打开的终端会话上打印(remember)。 - remote - 发送到 syslog 服务器(remote)。 - email - 将每条消息作为电子邮件发送(email-to)。 - script - 为每条消息运行脚本(script)。 |
memory-lines | num | 缓冲区保留的条目数,1..65535。缓冲区满时,除非设置了 memory-stop-on-full,否则每个新条目会丢弃最旧的条目。默认值:1000。 |
memory-stop-on-full | bool | 为 yes 时,缓冲区保留其前 memory-lines 个条目并丢弃新条目,直到使用 clear 清空。默认值:no。 |
disk-file-name | string | Name of the log files, without the extension. The action writes to <name>.0.txt; when that file is full, it becomes <name>.1.txt and a new <name>.0.txt starts. To write to another disk or folder, put its name first, for example usb1/log. The folder must exist, otherwise the action is refused with bad disk file name. Two disk actions cannot use the same file name. Default: log. |
disk-lines-per-file | num | 每个文件中的行数,达到后动作开始新文件,1..65535。默认值:1000。 |
disk-file-count | num | 动作保留的文件数,1..65535。开始新文件且达到计数时,最旧的文件及其条目会被丢弃。默认值:2。 |
disk-stop-on-full | bool | 日志文件满时停止写入此动作,而不是丢弃最旧的条目。默认值:no。 |
remote | alt { ipv6: ip6Addr , ip: ipAddr , hostname: string } | syslog 服务器的地址:IPv4 或 IPv6 地址或主机名。默认 remote 动作的地址为 0.0.0.0(未设置服务器)。默认值:0.0.0.0。 |
remote-port | num | syslog 服务器的端口。默认值:514。 |
src-address | alt { ipv6: ip6Addr , ip: ipAddr } | 发送到 syslog 服务器的数据包的源地址。0.0.0.0 由路由器选择。默认值:0.0.0.0。 |
remote-log-format | enum (default | syslog | cef) | 发送到 syslog 服务器的消息格式: - default(默认)- 主题和消息,<topics> <message>,不含时间或主机名。 - syslog - BSD syslog(RFC 3164):<PRI>(设施和严重性)、时间、路由器标识和消息。syslog-facility、syslog-severity、syslog-time-format 和 add-topics-string 适用于它。 - cef - 通用事件格式:时间和路由器标识,然后是 CEF:0|MikroTik|<model>|<version>|,包含主题、严重性(Low、Medium、High)以及字段 dvchost、dvc 和 msg,随后是消息的额外字段。每条消息以 cef-event-delimiter 结尾。 |
remote-protocol | enum (udp | tcp | tls) | 到 syslog 服务器的传输方式。每种格式都适用于每种传输方式,发送到相同地址和端口的动作共享一个连接。 - udp(默认)- 每条消息一个数据报。服务器不可达时发送的消息会丢失。 - tcp - 一个 TCP 连接。服务器不可达时记录的最多 1000 条消息(所有远程动作合计)保留在内存中,并在连接恢复时发送;缓冲区满时较新的消息会被丢弃。default 和 syslog 消息在流中没有分隔符;请通过 TCP 使用 cef。 - tls - 与 tcp 相同,但使用 TLS 加密(check-certificate)。 |
check-certificate | bool | For remote-protocol=tls: whether to verify the server certificate against the trusted certificates in /certificate. When the verification fails, the router does not send, logs ssld,error client session, logging, remote IP: <address>, ssl: no trusted CA certificate found and tries again later. The name in the certificate is not compared with the server address, so trust only the CA of your log servers. Default: no. |
cef-event-delimiter | string | 每条 cef 消息末尾添加的字符,通过 UDP 时也如此。默认值:\r\n。 |
syslog-time-format | enum (bsd-syslog | iso8601) | syslog 消息的时间格式: - bsd-syslog(默认)- Oct 2 16:51:21,路由器本地时间,不含年份。 - iso8601 - 2026-10-02T16:51:21.726+03:00,包含毫秒和时区偏移。 |
syslog-facility | enum (kern | user | mail | daemon | auth | syslog | lpr | news | uucp | cron | authpriv | ftp | ntp | local0 | local1 | local2 | local3 | local4 | local5 | local6 | local7) { kern:0, user:1, mail:2, daemon:3, auth:4, syslog:5, lpr:6, news:7, uucp:8, cron:9, authpriv:10, ftp:11, ntp:12, local0:16, local1:17, local2:18, local3:19, local4:20, local5:21, local6:22, local7:23 } | syslog 消息 <PRI> 中的设施及其代码: - kern (0) - user (1) - mail (2) - daemon (3)(默认) - auth (4) - syslog (5) - lpr (6) - news (7) - uucp (8) - cron (9) - authpriv (10) - ftp (11) - ntp (12) - local0 到 local7(16 到 23) |
syslog-severity | enum (auto | emergency | alert | critical | error | warning | notice | info | debug) { auto:0xffffffff, emergency:0, alert:1, critical:2, error:3, warning:4, notice:5, info:6, debug:7 } | syslog 消息 <PRI> 中的严重性。值不是 auto 时,每条消息都以该严重性发送。 - auto(默认)- 从消息主题获取严重性:debug 7、info 6、warning 4、error 3。同时带有 error 和 critical 的消息得到 3。 - emergency (0) - 系统不可用。 - alert (1) - 必须立即采取措施。 - critical (2) - 严重状况。 - error (3) - 错误状况。 - warning (4) - 警告状况。 - notice (5) - 重要状况。 - info (6) - 信息性消息。 - debug (7) - 调试消息。 |
email-to | string | Address the email action sends to. Each matching message is sent as its own email, with <topics> <message> as the subject and the body, through the SMTP server, port, TLS mode and sender set in /tool/e-mail. See Email. |
email-cc | multi { array-id, cc: string } | email 动作的额外收件人,位于 CC 头中。允许使用多个地址。 |
email-start-tls | bool | email 动作不使用:STARTTLS 遵循 /tool/e-mail 中的 tls 设置。默认值:no。 |
remember | bool | 对于 target=echo:保留没有终端会话打开时记录的消息,并在下次登录时打印一次。默认值:yes。 |
add-topics-string | bool | For remote-log-format=syslog: put the topics in front of the message, <PRI><time> <identity> <topics> <message>. The default format always contains the topics. Default: no. |
script | enum () | 对于 target=script:每条匹配消息要运行的 /system/script 中的脚本。脚本获得变量 $topics(主题文本,例如 system,error,critical)和 $message。脚本仍在运行时匹配的消息会被跳过,脚本自身记录的消息不会再次运行它。 |
vrf | enum () | 远程动作连接所使用的 VRF。默认值:main。 |