3.2. 在 Elytron 中启用文件审计日志记录
文件审计日志记录将审计日志消息存储在文件系统中的一个文件中。
默认情况下,Elytron 将 local-audit
指定为文件审计日志记录器。
您必须启用 local-audit
,以便它可以将 Elytron 审计日志写入单机服务器上的 EAP_HOME/standalone/log/audit.log
,或者用于受管域的 EAP_HOME/domain/log/audit.log
。
先决条件
您已保护了应用程序。
如需更多信息,请参阅在 Elytron 中创建一个
aggregate-realm
。
流程
创建文件审计日志。
语法
/subsystem=elytron/file-audit-log=<audit_log_name>:add(path="<path_to_log_file>",format=<format_type>,synchronized=<whether_to_log_immediately>)
Example
/subsystem=elytron/file-audit-log=exampleFileAuditLog:add(path="file-audit.log",relative-to=jboss.server.log.dir,format=SIMPLE,synchronized=true)
将文件审计日志添加到安全域。
语法
/subsystem=elytron/security-domain=<security_domain_name>:write-attribute(name=security-event-listener,value=<audit_log_name>)
Example
/subsystem=elytron/security-domain=exampleSecurityDomain:write-attribute(name=security-event-listener,value=exampleFileAuditLog)
验证
在浏览器中,登录您的安全应用。
例如,要登录到 使用安全域创建的应用程序来验证和授权应用程序用户,请导航到 http://localhost:8080/simple-webapp-example/secured 并登录。
导航到配置为存储审计日志的目录。如果您在流程中使用示例命令,则目录为 EAP_HOME/standalone/log。
请注意,创建一个名为
file-audit.log
的文件。它包含通过登录到应用程序来触发的事件的日志。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}
其他资源