3.2. Elytron のファイル監査ロギングの有効化
ファイル監査ロギングは、監査ログメッセージをファイルシステムにあるファイル 1 つに保存します。
デフォルトでは、Elytron はファイル監査ロガーとして local-audit を指定します。
local-audit を有効にして、スタンドアロンサーバーでは EAP_HOME/standalone/log/audit.log に、マネージドドメインでは EAP_HOME/domain/log/audit.log に、Elytron 監査ログを書き込めるようにする必要があります。
前提条件
アプリケーションをセキュリティー保護している。
詳細は、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>)例
/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>)例
/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}