JSF Web 应用程序用户日志记录。怎样做?
我正在开发的 Web 应用程序的管理员要求提供“我想知道一切”日志。他想要跟踪其他用户在连接(登录)到网络应用程序时所做的所有操作:
- 他/她访问了哪些页面。
- 他/她执行了哪些操作。
- 他/她对哪些实体(JPA 实体)执行了操作。
- 如果成功的话,她/他在什么具体时间执行给定的操作。
- 他/她修改了给定记录的哪些属性。
- 该用户的用户主体。
我现在能做的就是导出一个 CSV 文件,管理员可以在其中找到用户主体,即该用户登录和注销的时间。 我还在数据库中创建了一个示例历史记录表,由 EclipseLink 定制器填充,以跟踪相应表的更改。 (这个EclipseLink定制器的问题是它不灵活,因为数据库表随时间变化(添加/删除属性),所以是它们对应的实体。并且用户不想修改两次(一次在主表中,第二次在历史表中)!
?
- 是否有其他选择 解决方案,或与我相关的更好实践最好
的问候。
The administrator of the web application I am working on, asks for a 'I wanna know everything' log. He wants to track all what the other users did when they were connected (logged in) to the web app :
- What pages he/she visited.
- What actions he/she performed.
- On what entities (JPA Entities) he/she performed actions.
- At what exact time she/he performed a given action if successful.
- What attribute of the a given record he/she modified.
- The user principals of this user.
All I could do now, is export a CSV file where the administrator finds the user principals, the time this user logged in and logged out.
I also created an example history table in database populated by EclipseLink Customizer to track changes for a corresponding table. (The problem with this EclipseLink customizer is that it is not flexible, because database tables are changing with time (adding/removing attributes) and so are their corresponding entities. And the user does not want to modify things two times (one time in the main table and the second time in the history table)!
Could something like a third library 'log4j' do that?
- Is there any alternatives, solutions, or better practices related to my issu!?
Best regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看拦截器/侦听器 - JSF 可以获取页面/操作,JPA 也可以获取数据。在您的拦截器/侦听器中,您可以使用 log4j 记录到文件。
EclipseLink 侦听器
Hibernate 拦截器(用于比较)
JSF 监听器
Look into Interceptors/Listeners - both for JSF to get page/action and JPA to get data accessed. In your interceptors/listener you could then log to file using log4j.
EclipseLink Listeners
Hibernate Interceptors (for comparison)
JSF Listeners