# log-demo **Repository Path**: jedhe/log_demo ## Basic Information - **Project Name**: log-demo - **Description**: 生成随机日志数据到指定文件中,模拟生产环境应用日志产生,以便对日志进行采集分析和存储操作。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 6 - **Created**: 2024-09-12 - **Last Updated**: 2024-09-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 项目简介 生成随机日志数据到指定文件中,模拟生产环境应用日志产生,以便对日志进行采集分析和存储操作。 # 运行 ```bash pip install -r requirements.txt python main.py ``` # docker方式运行 ```bash [root@es-cold ~]# cd /opt/ [root@es-cold opt]# git clone https://gitee.com/cuiliang0302/log_demo.git [root@es-cold opt]# cd log_demo/ [root@es-cold log_demo]# ls Dockerfile log.py main.py readme.md requirements.txt [root@es-cold log_demo]# docker build -t log_demo:1.0 . [root@es-cold log_demo]# docker run -d -v $PWD/log:/opt/logDemo/log log_demo:1.0 [root@es-cold log_demo]# cd log [root@es-cold log]# ll total 76 -rw-r--r-- 1 root root 5526 Jul 19 21:53 error.log -rw-r--r-- 1 root root 28557 Jul 19 21:53 info.log -rw-r--r-- 1 root root 12266 Jul 19 21:53 warning.log ``` # 日志样例 ```bash 2023-07-20 22:50:12.475 | WARNING | __main__:debug_log:47 - {'access_status': 401, 'request_method': 'PUT', 'request_uri': '/management/', 'request_length': 25, 'remote_address': '163.231.28.163', 'server_name': 'cu-25.cn', 'time_start': '2023-07-20T22:50:12.444+08:00', 'time_finish': '2023-07-20T22:50:13.270+08:00', 'http_user_agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; Hot Lingo 2.0)'} 2023-07-20 22:50:13.023 | INFO | __main__:debug_log:49 - {'access_status': 200, 'request_method': 'POST', 'request_uri': '/management/', 'request_length': 52, 'remote_address': '157.229.223.122', 'server_name': 'cu-23.cn', 'time_start': '2023-07-20T22:50:12.427+08:00', 'time_finish': '2023-07-20T22:50:13.152+08:00', 'http_user_agent': 'Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36'} 2023-07-20 22:50:13.335 | ERROR | __main__:debug_log:45 - {'access_status': 504, 'request_method': 'GET', 'request_uri': '/account/', 'request_length': 47, 'remote_address': '160.3.80.228', 'server_name': 'cm-2.cn', 'time_start': '2023-07-20T22:50:13.093+08:00', 'time_finish': '2023-07-20T22:50:13.488+08:00', 'http_user_agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; Hot Lingo 2.0)'} 2023-07-20 22:50:14.158 | INFO | __main__:debug_log:49 - {'access_status': 200, 'request_method': 'DELETE', 'request_uri': '/management/', 'request_length': 12, 'remote_address': '134.46.86.93', 'server_name': 'cm-4.cn', 'time_start': '2023-07-20T22:50:14.062+08:00', 'time_finish': '2023-07-20T22:50:14.663+08:00', 'http_user_agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3451.0 Safari/537.36'} 2023-07-20 22:50:14.380 | INFO | __main__:debug_log:49 - {'access_status': 201, 'request_method': 'PUT', 'request_uri': '/account/', 'request_length': 29, 'remote_address': '203.30.85.45', 'server_name': 'cm-17.cn', 'time_start': '2023-07-20T22:50:14.244+08:00', 'time_finish': '2023-07-20T22:50:15.180+08:00', 'http_user_agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; Hot Lingo 2.0)'} 2023-07-20 22:50:15.058 | INFO | __main__:debug_log:49 - {'access_status': 200, 'request_method': 'GET', 'request_uri': '/account/', 'request_length': 58, 'remote_address': '172.38.27.228', 'server_name': 'cm-16.cn', 'time_start': '2023-07-20T22:50:14.900+08:00', 'time_finish': '2023-07-20T22:50:16.014+08:00', 'http_user_agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.2999.0 Safari/537.36'} ``` # other文件 包含geoip插件数据库文件和grafana dashboard数据。