We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 9 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(5)
因此,如果您正在寻找一个框架,您可以尝试 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.
如果您使用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)
这个怎么样 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.
您可以通过注释在没有 Spring 的情况下使用 AscpectJ 库
You can use AscpectJ library without Spring, via annotations
业务/操作级别日志记录的一个好方法是确定您到底需要记录什么。你已经这么做了。
您实际上不需要添加任何新框架或 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:
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.