在 Java 中记录并轻松查看大量会话数据

发布于 2024-09-08 06:09:09 字数 409 浏览 2 评论 0原文

我需要为我的 java web 应用程序设置一个日志系统,它不仅可以记录常用的内容(错误消息、错误级别等),还可以记录其他信息,例如会话 ID。当然,我想我可以将会话 ID 放入错误消息中,但问题是我最终会为许多不同的用户记录大量数据,并且我需要最终拥有一个可以查看日志的系统并根据会话 ID 对日志进行排序。

我一直在研究 log4j 与链锯的结合,我想我可以 扩展 log4j 添加附加属性 这很棒,但是如何在链锯中查看这些自定义属性呢?

当然我不是第一个遇到这个问题的人,除了 log4j 与链锯结合之外,还有其他我可以使用的东西吗?

I need to set up a logging system for my java web application that not only logs the usual stuff (error message, error level, etc) but can also log additional information as well such as session ID. Sure I suppose I could put the session ID in the error message, but the problem is that I will end up logging lots and lots of data for lots of different users and I need to end up having a system where I can look at the log and sort the log based on session ID.

I've been looking at log4j coupled with chainsaw, and I think I could extend log4j to add additional attributes which is great, but then how do I view those custom attributes in chainsaw?

Surely i'm not the first one to have had this problem, is there something else I could use besides log4j coupled with chainsaw?

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

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

发布评论

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

评论(4

生寂 2024-09-15 06:09:09

我不知道链锯,但记录额外的横切信息,如会话 ID、用户名、请求 ip 等通常是通过 嵌套诊断上下文

I don't know chainsaw, but logging additional cross-cutting information such as session ids, user names, requesting ip, ... is usually done through the nested diagnostic context.

浅唱々樱花落 2024-09-15 06:09:09

免责声明:我是 Chainsaw 的提交者之一...

Chainsaw 将在其自己的列中显示 NDC 值,并将所有 MDC 条目显示为自己的列。

即将发布的版本(很快)将推出许多新功能,使过滤、着色、搜索和排序变得容易。或者,通过 svn 拉取 Chainsaw + log4j 同伴并使用 Maven 构建...

一个非常方便的功能:能够向单个事件添加评论,从 Chainsaw 内部保存事件并将结果文件通过电子邮件发送给其他人,他们可以在表中看到您的评论。

这是一个屏幕视频: http://people.apache.org/~sdeboy/chainsawdemo.avi

Disclaimer: I'm one of Chainsaw's committers...

Chainsaw will display the NDC value in its own column, and will display any MDC entries as their own column as well.

Lots of new features coming in the upcoming release (soon) which make it easy to filter, colorize, search and sort..or, pull Chainsaw + the log4j companions down via svn and build with maven...

One really handy feature: the ability to add comments to individual events, save off the events from inside Chainsaw and email the resulting file to others, who can see your comments in the table.

Here's a screen video: http://people.apache.org/~sdeboy/chainsawdemo.avi

风柔一江水 2024-09-15 06:09:09

您正在记录审核您的用户吗?

审核涉及审查用户操作,作为正常操作的一部分,并且属于数据库。

日志记录更多的是用于中断/修复。

Are you logging or auditing your users?

Auditing involves reviewing user actions as a part of normal operations and belongs in a database.

Logging is more for break/fix.

放飞的风筝 2024-09-15 06:09:09

最好的办法是将这些数据插入数据库。这样,您就可以在会话 ID 上建立索引,并使用直接 SQL 快速检索和排序所有信息,或者创建一个轻量级 Web 应用程序,用于在给定会话 ID 或其他搜索条件的情况下查看数据库中的数据。

如果您想要一个可以将现有日志文件输入到其中的快速解决方案 - 尝试 splunk

HTH

Best thing to do would be to insert that data into a database. That way you can have indexes on session id and quickly retrieve and sort all the information either using straight SQL, or creating a light weight webapp for viewing the data from the database given a session id or other criteria to search on.

If you want a quick solution that you can feed existing log files into - try out splunk

HTH

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文