业务审计日志 - 推荐的库或方法?

发布于 2024-09-24 18:54:25 字数 1539 浏览 2 评论 0原文

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

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

发布评论

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

评论(5

丶视觉 2024-10-01 18:54:25

因此,如果您正在寻找一个框架,您可以尝试 logback-audit。它是由 Java 日志库 logback 背后的人们编写的。

So, if you are looking for a framework, you could try logback-audit. It is by the folks who are behind the Java logging library, logback.

愚人国度 2024-10-01 18:54:25

如果您使用Java,一种方法是使用springframework和aop。这是最灵活的选择。 这是一个示例

您还可以使用 hibernate 在数据库级别执行此操作 (更多信息)

If you are using Java, one way is to use springframework and aop. This is the most flexible option. Here is an example

You can also do it at database level using hibernate (more info)

岁月流歌 2024-10-01 18:54:25

这个怎么样 https://github.com/dima767/inspektr
我的要求与您上面描述的几乎相同,并且正在深入研究 inspektr。

what about this https://github.com/dima767/inspektr
I have almost the same requirements as you described above, and am digging into inspektr.

林空鹿饮溪 2024-10-01 18:54:25

您可以通过注释在没有 Spring 的情况下使用 AscpectJ 库

You can use AscpectJ library without Spring, via annotations

看春风乍起 2024-10-01 18:54:25

业务/操作级别日志记录的一个好方法是确定您到底需要记录什么。你已经这么做了。

您实际上不需要添加任何新框架或 AOP。但是,您有一些额外的要求,这些要求阻止您在不创建更多工作的情况下使用常见的日志记录框架(例如 Log4J 或 java.util.logging)。

我能想到的最简单的方法是使用一个 Audit 类,其中注入或配置了 JDBC 连接。如果您已经在使用该框架,则可以通过 Spring 完成此操作。如果您没有 DI 容器,那么您需要将其定义为单例。

您需要的另一件事是签名能力。 Java 有一个 java.security.Signature 来签名和验证数据。

正如我之前所说,您的要求会阻止您使用可用的日志记录框架。即:

  • 基于元数据搜索审核日志

为了方便搜索,您需要将数据存储在数据库中,因为写入文本文件将很困难。使用日志框架,您必须学习 API 并绑定到不属于标准的框架。

A good approach to business/operation level logging is to determine what exactly you need to log. You have already done that.

You don't really need any new framework or AOP to add. However, you have some extra requirements which prevent you from using the common logging frameworks such as Log4J or java.util.logging without creating more work.

The easiest approach I can think of you can do is to have a Audit class that has a JDBC connection injected or configured in it. This can be done through Spring if you are already using that framework. If you don't have a DI container then you need to define this as a singleton.

Another thing you need is a capability of signing. Java has a java.security.Signature to sign and verify data.

As I said earlier you have requirements that prevent you from using the available logging frameworks. That is:

  • search audit log based on metadata

For you to facilitate searching you need to store data in a database as writing to a text file will be difficult to do. Using the logging frameworks you have to learn the API and be tied to the framework which is not part of the standard.

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