3.3. 在 Elytron 中启用定期轮转文件审计日志记录
您可以使用 elytron
子系统为单机服务器或作为受管域运行的服务器启用定期轮转文件审计日志记录。
定期轮转文件审计日志记录会根据您配置的调度自动轮转审计日志文件。定期轮转文件审计日志记录与默认文件审计日志记录类似,但定期轮转文件审计日志记录包含额外的属性: suffix
。
suffix
属性的值是一个使用 java.time.format.DateTimeFormatter
格式指定的日期,如 .yyyy-MM-dd
。Elytron 自动从后缀提供的值计算轮转周期。elytron
子系统在日志文件名称末尾附加后缀。
先决条件
您已保护了应用程序。
如需更多信息,请参阅在 Elytron 中创建一个
aggregate-realm
。
流程
创建定期轮转文件审计日志。
语法
/subsystem=elytron/periodic-rotating-file-audit-log=<periodic_audit_log_name>:add(path="<periodic_audit_log_filename>",format=<record_format>,synchronized=<whether_to_log_immediately>,suffix="<suffix_in_DateTimeFormatter_format>")
/subsystem=elytron/periodic-rotating-file-audit-log=<periodic_audit_log_name>:add(path="<periodic_audit_log_filename>",format=<record_format>,synchronized=<whether_to_log_immediately>,suffix="<suffix_in_DateTimeFormatter_format>")
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
/subsystem=elytron/periodic-rotating-file-audit-log=examplePreiodicFileAuditLog:add(path="periodic-file-audit.log",relative-to=jboss.server.log.dir,format=SIMPLE,synchronized=true,suffix="yyyy-MM-dd")
/subsystem=elytron/periodic-rotating-file-audit-log=examplePreiodicFileAuditLog:add(path="periodic-file-audit.log",relative-to=jboss.server.log.dir,format=SIMPLE,synchronized=true,suffix="yyyy-MM-dd")
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将定期轮转文件审计日志记录器添加到安全域。
语法
/subsystem=elytron/security-domain=<security_domain_name>:write-attribute(name=security-event-listener,value=<periodic_audit_log_name>)
/subsystem=elytron/security-domain=<security_domain_name>:write-attribute(name=security-event-listener,value=<periodic_audit_log_name>)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example
/subsystem=elytron/security-domain=exampleSecurityDomain:write-attribute(name=security-event-listener,value=examplePreiodicFileAuditLog)
/subsystem=elytron/security-domain=exampleSecurityDomain:write-attribute(name=security-event-listener,value=examplePreiodicFileAuditLog)
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
验证
在浏览器中,登录您的安全应用。
例如,要登录到 使用安全域创建的应用程序来验证和授权应用程序用户,请导航到 http://localhost:8080/simple-webapp-example/secured 并登录。
导航到配置为存储审计日志的目录。如果您在流程中使用示例命令,则目录为 EAP_HOME/standalone/log。
请注意,创建一个名为
periodic-file-audit.log
的文件。它包含通过登录到应用程序来触发的事件的日志。periodic-file-audit.log 文件示例
2023-10-24 23:31:04,WARNING,{event=SecurityPermissionCheckSuccessfulEvent,event-time=2023-10-24 23:31:04,security-identity=[name=user1,creation-time=2023-10-24 23:31:04],success=true,permission=[type=org.wildfly.security.auth.permission.LoginPermission,actions=,name=]} 2023-10-24 23:31:04,WARNING,{event=SecurityAuthenticationSuccessfulEvent,event-time=2023-10-24 23:31:04,security-identity=[name=user1,creation-time=2023-10-24 23:31:04],success=true}
2023-10-24 23:31:04,WARNING,{event=SecurityPermissionCheckSuccessfulEvent,event-time=2023-10-24 23:31:04,security-identity=[name=user1,creation-time=2023-10-24 23:31:04],success=true,permission=[type=org.wildfly.security.auth.permission.LoginPermission,actions=,name=]} 2023-10-24 23:31:04,WARNING,{event=SecurityAuthenticationSuccessfulEvent,event-time=2023-10-24 23:31:04,security-identity=[name=user1,creation-time=2023-10-24 23:31:04],success=true}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow