james-ban/yii2-logstash
Composer 安装命令:
composer require james-ban/yii2-logstash
包简介
yii2 logstash
README 文档
README
Yii2配置
-
安装
composer require james-ban/yii2-logstash
-
修改
app/config/web.php添加LogstashFileTarget部分<?php .... 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ .... [ 'class' => 'Log\LogstashFileTarget', 'levels' => ['error', 'warning'], 'except' => ['yii\web\HttpException:404', 'yii\web\HttpException:403', 'yii\debug\Module::checkAccess', 'yii\web\HttpException:400', 'yii\base\UserException', 'yii\web\HttpException:401'], 'logFile' => '@runtime/logs/logstash.log', ] .... ], ], ..... ?>
Logstatsh配置文件
- 将
yii2.conf放置在/etc/logstash/conf.d下
input {
file {
type => "prod"
path => "$project_path/app/runtime/logs/logstash.log"
#start_position => "end"
codec => "json"
}
}
output {
if [type] == "prod" {
elasticsearch {
hosts => ["$elasticsearch_host:$elasticsearch_port"]
index => "yii-web-%{+YYYY-MM-dd}"
document_type => "yii2"
workers => 1
#flush_size => 20000
#idle_flush_time => 10
}
}
}
-
重启 logstatsh
# /etc/init.d/logstash Usage: {start|stop|force-stop|status|reload|restart|configtest}
统计信息
- 总下载量: 433
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2019-11-11