Sign inSign up

dreamplay/log

By dreamplay

•Updated almost 7 years ago

基于redis、MongoDB、PHP、nginx、kafka技术实现的日志系统

Image
0

1.2K

dreamplay/log repository overview

⁠基于redis、MongoDB、PHP、nginx技术实现的日志系统

  • 使用docker-compose部署,编辑docker-compose.yml配置如下
version: '2'
services:
  log:
    image: dreamplay/log
    restart: always
    tty: true
    ports:
      - 8888:80
  • 运行起来之后,就可以访问后台了
访问:http://ip:8888/
  • 默认配置
appid:admin
appsecret:linzhou
  • 相关接口
  1. 获取access_token接口
GET:http://ip:8888/api/getAccessToken
参数:
appid:admin
appsecret:linzhou
返回结果:
{
    "message": "获取成功",
    "code": 200,
    "info": {
        "access_token": "XXXXXXXXXXXX",
        "token_type": "Bearer",
        "expires_in": 7200
    }
}
  1. 记录日志接口
POST:http://ip:8888/api/saveLog
参数:
{
    "authorization":"XXXXXXXXXXXX",
    "project_name": "test",
    "level": "error", //日志等级
    "message":"日志摘要信息",
    "other":"其他信息",
    "ip":"127.0.0.1/127.0.0.1",
    "create_time":"2019-11-11 18:18:18"
}
返回结果:
{
    "message": "保存成功",
    "code": 200,
    "info": []
}
  1. kafka方式
            $param = [
                'project_name' => config('app.app_name') ?: 'common_log',
                'level' => $level,
                'ip' => ($_SERVER['SERVER_ADDR'] ?? '127.0.0.1') . '/' . request()->ip(),
                'message' => $message,
                'other' => $other,
                'create_time' => date('Y-m-d H:i:s'),
            ];
            if (config('app.common_log.use_kafka')) {
                KafkaHelper::instance(config('app.common_log.kafka_brokers'), 'common_log')->produce($param);
                return true;
            }

Tag summary

Content type

Image

Digest

Size

1 GB

Last updated

almost 7 years ago

docker pull dreamplay/log