syslog输出器

功能描述

syslog输出器能够将程序运行中产生的日志内容输出远端的syslog服务器。

OpenAPI配置日志

配置参数说明

参数名值类型是否必填值可能性默认值说明
namestring实例名
driverstringsyslog_output驱动名
descriptionstring描述
scopes[]string作用域,此处填写access_log
networkstring["tcp","udp","unix"]所使用的网络协议, 如:tcp,udp,unix
addressstring远端syslog服务器的地址
levelstring["error","warn","info","debug","trace"]日志等级
typestring["line","json"]lineformatter的类型
formatterobjectformatter的输出内容

注意

  • formatter的配置教程点此进行跳转

返回参数说明

参数名类型是否必含说明
idstring实例id
namestring实例名
driverstring驱动名
descriptionstring描述
professionstring模块名
createstring创建时间
updatestring更新时间
scopes[]string作用域,此处填写access_log
networkstring所使用的网络协议, 如:tcp,udp,unix
addressstring远端syslog服务器的地址
levelstring日志等级
typestringformatter的类型
formatterobjectformatter的输出内容

创建syslog输出器示例

curl -X POST  \
  'http://127.0.0.1:9400/api/output' \
  -H 'Content-Type:application/json' \
  -d '{
	"name": "demo_syslog",
	"driver": "syslog_output",
	"network": "tcp",
	"address": "127.0.0.1:514",
	"level": "info",
	"type": "line",
	"scopes": ["access_log"],
	"formatter": {
		"fields": ["$request_id", "$request", "$status", "@time", "@proxy", "$response_time"],
		"time": ["$msec", "$time_iso8601", "$time_local"],
		"proxy": ["$proxy_uri", "$proxy_scheme", "$proxy_addr"]
	}
}'

返回结果示例

{
	"address": "127.0.0.1:514",
	"create": "2022-06-14 14:56:15",
	"description": "",
	"driver": "syslog_output",
    "scopes": ["access_log"],
	"formatter": {
		"fields": ["$request_id", "$request", "$status", "@time", "@proxy", "$response_time"],
		"proxy": ["$proxy_uri", "$proxy_scheme", "$proxy_addr"],
		"time": ["$msec", "$time_iso8601", "$time_local"]
	},
	"id": "demo_syslog@output",
	"level": "info",
	"name": "demo_syslog",
	"network": "tcp",
	"profession": "output",
	"type": "line",
	"update": "2022-06-14 14:56:15"
}

syslog输出器使用

syslog输出器可用于access-log插件的日志输出,点此跳转至access-log插件。