什么是解析日志文件的最佳工具? [英] What's the best tool to parse log files?

查看:71
本文介绍了什么是解析日志文件的最佳工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用grep解析我的交易应用程序日志,但是从某种意义上讲,我需要在视觉上浏览输出以查看发生了什么情况,这是有局限性的.

I use grep to parse through my trading apps logs, but it's limited in the sense that I need to visually trawl through the output to see what happened etc.

我想知道Perl是否是更好的选择?有什么好的资源来学习Perl的日志和字符串解析吗?

I'm wondering if Perl is a better option? Any good resources to learn log and string parsing with Perl?

我也相信Python会很好. Perl vs Python vs"Linux上的grep"?

I'd also believe that Python would be good for this. Perl vs Python vs 'grep on linux'?

推荐答案

最后,这实际上取决于您要识别多少语义,您的日志是否适合通用模式以及要对解析的数据进行什么处理

In the end, it really depends on how much semantics you want to identify, whether your logs fit common patterns, and what you want to do with the parsed data.

如果您可以使用正则表达式查找所需内容,则有很多选择. Perl是一种流行的语言,具有非常方便的本地RE设施.我个人对Python感到更自在,并且发现执行RE所带来的一点麻烦并不重要.

If you can use regular expressions to find what you need, you have tons of options. Perl is a popular language and has very convenient native RE facilities. I personally feel a lot more comfortable with Python and find that the little added hassle for doing REs is not significant.

如果您想做一些比RE匹配更智能的事情,或者想拥有很多逻辑,那么您可能更喜欢Python甚至Java/C ++/etc.例如,很容易在Python中逐行读取内容,然后将各种谓词函数和响应应用于匹配,如果您有要应用的规则集,那就很好了.

If you want to do something smarter than RE matching, or want to have a lot of logic, you may be more comfortable with Python or even with Java/C++/etc. For instance, it is easy to read line-by-line in Python and then apply various predicate functions and reactions to matches, which is great if you have a ruleset you would like to apply.

这篇关于什么是解析日志文件的最佳工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆