基于redis、MongoDB、PHP、nginx、kafka技术实现的日志系统
1.2K
version: '2'
services:
log:
image: dreamplay/log
restart: always
tty: true
ports:
- 8888:80
访问:http://ip:8888/
appid:admin
appsecret:linzhou
GET:http://ip:8888/api/getAccessToken
参数:
appid:admin
appsecret:linzhou
返回结果:
{
"message": "获取成功",
"code": 200,
"info": {
"access_token": "XXXXXXXXXXXX",
"token_type": "Bearer",
"expires_in": 7200
}
}
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": []
}
$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;
}
Content type
Image
Digest
Size
1 GB
Last updated
almost 7 years ago
docker pull dreamplay/log