python - Python 排除行正则表达式字符串等(python 日志记录/Ookla 服务器
问题描述
我正在使用 Ookla Server,它在端口 8080 上运行,并对移动应用程序(不是 HTTP)端进行速度测试
它记录了太多冗长,它设置为应用程序,唯一的错误是另一个选项
它每秒记录这样的数据,日志太大太多信息
[14/Jun/2021:17:46:46 GMT] "Disconnect NetException: Connection reset by peer" "" ""
[14/Jun/2021:17:46:46 GMT] "Disconnect NetException: Connection reset by peer" "" ""
[14/Jun/2021:17:46:46 GMT] "Disconnect NetException: Connection reset by peer" "" ""
[14/Jun/2021:17:46:47 GMT] "TCP uptime: 101 - total current: 2, queued: 0, blocked: 0, queueFull: 0, concurrent: 6, currentThreads: 4" "" ""
我尝试了不同的选项来排除“TCP”行,例如(从我的 ooklaserver.properties 配置中)与我在堆栈溢出中找到的正则表达式数据
#logging.loggers.app.name = Application
logging.loggers.app.channel.class = FileChannel
#logging.loggers.app.channel.pattern = %Y-%m-%d %H:%M:%S [%P - %I] [%p] %t
#logging.loggers.app.channel.pattern = %[client_plaintext] - %[session] [%d/%b/%Y:%H:%M:%S %Z] "%t" %[status] %[size] "%[referer]" "%[useragent]"
#logging.loggers.app.channel.pattern = %[client_plaintext] - %[session] [%d/%b/%Y:%H:%M:%S %Z] "%[referer]" "%[useragent]"
logging.loggers.app.channel.pattern = sub(r'(?<!\b[ia])t\b', '', TCP) (r'^(?!/TCP).*$') %[client_plaintext] - [%d/%b/%Y:%H:%M:%S %Z] "%t" %[size] "%[referer]" "%[useragent]"
logging.loggers.app.channel.path = ${application.dir}/ooklaserver.log
也许排除部分必须在不同的命令中运行并重写?基本上,我只想记录 IP 和时间...
尝试 了如何在 Python 中使用正则表达式排除特定字符串? 使用正则表达式排除字符串搜索中的字符? 如何从正则表达式组中排除字符? 排除单词/字符串的正则表达式 非常感谢!
解决方案
推荐阅读
- swift - 在范围内找不到“CodingKeys”,错误不一致
- elasticsearch - Elasticsearch - 是否可以在查询中执行空间连接?
- docker - 将管理器添加回 swarm 集群
- stm32 - STM32L4 ADC 不工作(多通道无 DMA)
- html - CSS树结构1-4-3
- c - 在 KVM 中拦截 RDTSC 指令
- python - 在 Python 中从麦克风录制音频
- javascript - 如何防止表单提交之前并发送ajax请求
- r - 加权数据可以与 R 中的 CrossTable 函数一起使用吗?
- java - 从 for 循环内部跳到下一个 if 语句