Integration with SAP Audit Logging Service
The SAP Audit Logging Service enables you to record security-relevant events in your applications running on SAP Business Technology Platform (SAP BTP). This guide explains how to integrate your CAP application with the Audit Logging Service.
Prerequisites
To use the Audit Logging Service, ensure that:
- Your SAP BTP subaccount has the Audit Logging Service instance created.
- Your CAP application is bound to the Audit Logging Service instance using a service key.
Setting Up Audit Logging in Your CAP Application
Install the Required Package:
Ensure that you have the
@sap/audit-loggingpackage installed in your CAP project:bashnpm install @sap/audit-loggingConfigure the Audit Logger:
In your application code, configure the audit logger using the service credentials from the service key:
javascriptconst { AuditLogger } = require('@sap/audit-logging'); const auditLogger = new AuditLogger({ // Provide necessary configuration options here });Log Events:
Use the audit logger to log security-relevant events in your application:
javascriptauditLogger.logEvent({ eventType: 'USER_LOGIN', user: 'username', details: { // Additional event details } });
Further Reading
For more detailed information on configuring and using the SAP Audit Logging Service, refer to the official documentation.