我试图找到一个解决方案,快速合并来自2个应用程序服务器的2个日志文件。日志文件如下:
00:00:00,028 DEBUG [com.acme.productionservice...
我想根据时间戳打印日志文件的一行或另一行,例如:
如果文件1具有2行:
00:00:00,028 DEBUG [com.acme.productionservice...
00:00:00,128 DEBUG [com.acme.productionservice...
文件2有3行:
00:00:00,045 DEBUG [com.acme.productionservice...
00:00:00,100 DEBUG [com.acme.productionservice...
00:00:00,150 DEBUG [com.acme.productionservice...
输出应该是
00:00:00,028 DEBUG [com.acme.productionservice... (file 1)
00:00:00,045 DEBUG [com.acme.productionservice... (file 2)
00:00:00,100 DEBUG [com.acme.productionservice... (file 2)
00:00:00,128 DEBUG [com.acme.productionservice... (file 1)
00:00:00,150 DEBUG [com.acme.productionservice... (file 2)
我目前知道唯一方法是使用cat file1 file|排序,但这是非常缓慢的GB的日志,我需要一些像阅读2个文件,比较时间戳,并决定打印什么。
2条答案
按热度按时间yi0zb3m41#
最后我用了
我还使用了一个技巧来了解日志来自哪个日志文件,
rsaldnfx2#
尝试Super Speedy Syslog Searcher
(假设您有rust installed)
然后
但是,Super Speedy Syslog Searcher 期望找到 date 时间戳。如果您可以将日志记录格式从timestamp更改为datestamp,则
s4
可以对行进行排序和合并。