如何使用日志文件

发布于 2024-12-01 16:34:59 字数 192 浏览 0 评论 0原文

通常,在我在编辑器中打开日志之前,我会通过大量的 grep 管道来消除“噪音”。

我认为应该可以在编辑器(尤其是 Emacs)内进行此过滤,

这是链锯正在做的事情吗?仅适用于 log4j 格式还是更通用? (这是我能找到的唯一日志文件查看器工具)

你们是怎么做到的? (我认为 UNIX grep 语法对我来说是最简单的)

Usually I pipe my log through a lot of greps to remove the "noise" before i open it in an editor.

I think it should be possible to do this filtering inside an editor (Especially Emacs)

Is this what chainsaw is doing? For log4j format only or more general?
(It is the only logfile viewer tool I can find)

How do you guys do it?
(I think UNIX grep syntax would be easiest for me)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

醉生梦死 2024-12-08 16:34:59

Chainsaw 支持正向和负向滤波器匹配。您可以根据记录器树定义正匹配和负匹配(右键单击选项的节点),并且可以在“优化焦点”字段中定义正匹配表达式,并使用下面的“忽略”选项定义负匹配表达式记录器树。帮助菜单中有一个教程,其中描述了表达式语法。

自上次正式发布以来,Chainsaw 添加了许多新功能。开发人员快照(包括重新设计的配置屏幕)可在此处获取:

http://people.apache.org/~sdeboy

Chainsaw 不仅仅适用于 log4j。有一些“接收器”可以使其与 log4net、java.util.logging、log4php 等一起使用。

您还可以使用 VFSLogFilePatternReceiver 处理任何常规格式的文本文件(使用“处理日志文件”选项来配置 Chainsaw 来定义一个文件)。配置对话框中有一些预定义的日志格式可用作示例格式 - 调整一种格式以匹配您的格式。 JavaDoc 提供了更多信息: http://logging .apache.org/chainsaw/apidocs/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.html

Chainsaw does support both positive and negative filter matching. You can define positive and negative matches based on the logger tree (right click on nodes for the options), and you can define positive-match expressions in the 'refine focus' field, and negative-match expressions using the 'ignore' option below the logger tree. There is a tutorial available from the help menu which describes the expression syntax.

Chainsaw has had a lot of new features added since the last official release. The developer snapshot (including a reworked configuration screen) is available here:

http://people.apache.org/~sdeboy

Chainsaw doesn't just work with log4j. There are 'receivers' available that make it work with log4net, java.util.logging, log4php and others.

You can also process any regularly formatted text file using a VFSLogFilePatternReceiver (use the 'process a log file' option to configure Chainsaw to define one). There are some pre-defined log formats in the configuration dialog that act as example formats - tweak one to match your format. The JavaDoc provides more information: http://logging.apache.org/chainsaw/apidocs/org/apache/log4j/chainsaw/vfs/VFSLogFilePatternReceiver.html

拥抱我好吗 2024-12-08 16:34:59

如果 grep 相同,您可以简单地编写一个脚本来为您完成所有工作(例如 vimscript 对于 vi)。这样,您就不必重复所有任务,同时保留完整的日志以供进一步调查。

你说得对的是链锯和log4j——它是一个具有不同功能的日志查看器,例如过滤机制。但是,我不确定您是否能够同时激活多个过滤器。

If the greps are the same, you can simply code a script to do all that work for you (e.g. vimscript for vi). That way, you don't have to repeat all the tasks while leaving the logs intact for further investigation.

You're right on chainsaw and log4j - it's a logging viewer with different capabilities, e.g. a filter mechanism. However, I am unsure, if you are able to have multiple filters activated simultaneously.

冷清清 2024-12-08 16:34:59

是的,您应该首先尝试 Chainsaw..它确实支持各种获取日志的方式。

Yes, you should try Chainsaw first.. it does support various ways of getting your logs.

往事随风而去 2024-12-08 16:34:59

Necroposting:我创建了一个 Emacs 模式,专门针对类似 Log4j 的日志,但支持更多格式,特别是如果您为自己定制的话。

特点:

  • 着色(如果太多,只需自定义面孔)
  • 在同一缓冲区中进行交互式过滤:
    • 按级别
    • 按记录器名称
    • 按线程
    • 通过消息
    • 轻松缩小范围
    • 一次性编辑所有当前设置的过滤器
  • 一些特定于日志的移动命令
  • 仅复制(使用 Mw)可见文本,与过滤配合良好(这是可定制的)

Necroposting: I created a mode for Emacs that is specifically targeted at Log4j-like logs, but supports many more formats, especially if you customize it for yourself.

Features:

  • Colorization (just customize faces if that's too much)
  • Interactive filtering in the same buffer:
    • by level
    • by logger name
    • by thread
    • by message
    • easy narrowing
    • edit all currently set filters at once
  • A few log-specific movement commands
  • Copy (with M-w) only visible text, goes well with filtering (this is customizable)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文