@cap-js/audit-logging
Integration with the SAP Audit Log serviceSAP Audit Log serviceIngests compliance audit data from BTP services and applications and keeps it for ninety days by default; retrieval and longer retention are separate services.sap official, btp, so operations on personal data are recorded in the form an auditor expects without the application writing the entries.
Facts
Where it sits
Who is behind it
In the atlas: maintains 34@cap-jsmaintainerAjinkya PatilContributes to this
In the atlas: contributes to 112@ajinkyapatil8190Arley Triana MorinContributes to this
In the atlas: contributes to 9, wrote 1@arleytmChristian GeorgiContributes to this
In the atlas: maintains 1, contributes to 53@chgeoChristian SchüringsContributes to this
In the atlas: contributes to 25@cschueringsDaniel HutzelContributes to this
In the atlas: contributes to 32, wrote 3@danjoaDr. David A. KunzContributes to this
In the atlas: contributes to 16@David-KunzGuilherme DellagustinContributes to this
In the atlas: contributes to 27@dellagustin-sapNikolay GrechanovContributes to this
In the atlas: contributes to 1@grenikHeiko WitteborgContributes to this
In the atlas: contributes to 18@hm23Johannes VogelContributes to this
In the atlas: contributes to 25@johannes-vogel25 contributors
Before choosing this
Conditions
LicenceSAP Developer License Agreement 3.2 CAP§ 1, 2, 3A cds-plugin is used with SAP CAP materials, or an artifact is explicitly identified as a CAP plugin or application.
- § 1 License. Productive customer applications are limited to SAP BTP or another SAP-licensed platform, and mass extraction to a non-SAP product is restricted except where solely required for SAP interoperability.
- § 2 Intellectual Property. The agreement retains SAP's rights in the covered materials and limits making APIs, tools or software available to third parties, while preserving ownership of customer applications subject to SAP's underlying rights.
- § 3 Artificial Intelligence Training. The agreement prohibits use of the covered materials and customer applications for training artificial-intelligence models or systems.
What it declares
Every artifact
- Type
- CDS plugin
- Origin
- By SAP
As a CDS plugin
- Declared for
- >=9
- Distributed through
- npm
Connections
Recording who touched personal or sensitive data, for auditors
Seeing what a running service did, in a readable form
Ingests and retains compliance audit data from BTP
Ingests and retains compliance audit data from BTP
Download
Install
npm add @cap-js/audit-loggingDerived from the package name. No recipe recorded; the README has the configuration.
Learn more
- Implementing Custom Audit Logging in SAP CAP ApplicationsImplementing Custom Audit Logging in SAP CAP ApplicationsWhere the annotations stop. CAP logs personal-data operations automatically once a model is annotated; this is about the events that are not that — an unauthorised access attempt, a business action somebody wants a trail for — and what writing those yourself involves.gopalanand, published 2025-10-09gopalanand, SAP Community
- How to implement SAP BTP Audit log service in a CAP ApplicationHow to implement SAP BTP Audit log service in a CAP ApplicationThe setup half: binding the BTP Audit Log service to a CAP application and getting the annotated path working, which is the step before anything custom becomes a question.KrishnaSharma7, published 2025-01-01KrishnaSharma7, SAP Community
- Makes stale:
Setup notes that add the plugin to a CAP 8 project.
1 earlier
- v0.1.0
Logs are written with
audit.log()andaudit.logSync()against the SAP Audit Log Service REST API instead of through the@sap/audit-loggingclient library. The eventsdataAccessLog,dataModificationLog,configChangeLogandsecurityLogare removed,@AuditLog.Operationannotations are ignored, and reading sensitive data is logged only whencds.requires['audit-log'].handleincludesREAD.Makes stale:Guides that set
cds.features.audit_personal_data: true, annotate entities with@AuditLog.Operation, or expect reads of sensitive data to be logged by default.
Where it sits in your app
Download
README
quoted from cap-js/audit-logging under Apache-2.0, readWelcome to @cap-js/audit-logging
@cap-js/audit-logging is a CDS plugin providing integration to the SAP Audit Log service as well as out-of-the-box personal data-related audit logging based on annotations.
Documentation can be found at cap.cloud.sap.
Important
The information in this file is by no means complete but enables you to get started quickly. Make sure to read the provided documentation at cap.cloud.sap to get the full picture.
Preliminaries
In this guide, we use the Incidents Management reference sample app as the base to add change tracking to. Clone the repository and apply the step-by-step instructions:
git clone https://github.com/cap-js/incidents-app
cd incidents-app
npm i
Setup
To enable audit logging, simply add this self-configuring plugin package to your project:
npm add @cap-js/audit-logging
Annotate Personal Data
Identify entities and elements (potentially) holding personal data using @PersonalData annotations. Create a db/data-privacy.cds file and add the following:
using { sap.capire.incidents as my } from './schema';
annotate my.Customers with @PersonalData : {
DataSubjectRole : 'Customer',
EntitySemantics : 'DataSubject'
} {
ID @PersonalData.FieldSemantics: 'DataSubjectID';
firstName @PersonalData.IsPotentiallyPersonal;
lastName @PersonalData.IsPotentiallyPersonal;
email @PersonalData.IsPotentiallyPersonal;
phone @PersonalData.IsPotentiallyPersonal;
creditCardNo @PersonalData.IsPotentiallySensitive;
};
annotate my.Addresses with @PersonalData: {
EntitySemantics : 'DataSubjectDetails'
} {
customer @PersonalData.FieldSemantics: 'DataSubjectID';
city @PersonalData.IsPotentiallyPersonal;
postCode @PersonalData.IsPotentiallyPersonal;
streetAddress @PersonalData.IsPotentiallyPersonal;
};
annotate my.Incidents with @PersonalData : {
EntitySemantics : 'Other'
} {
customer @PersonalData.FieldSemantics: 'DataSubjectID';
};
Learn more about the annotations in capire:
- @PersonalData.EntitySemantics
- @PersonalData.EntitySemantics: 'DataSubject'
- @PersonalData.FieldSemantics: 'DataSubjectID'
- @PersonalData.IsPotentiallyPersonal
- @PersonalData.IsPotentiallySensitive
Test-Drive Locally
You've prepared everything to log personal data-related events. Let's see that in action.
Start the server as usual:
cds watch
Send an update request that changes personal data:
PATCH http://localhost:4004/odata/v4/admin/Customers('1004155')
Authorization: Basic alice:in-wonderland
Content-Type: application/json
{
"firstName": "Danny",
"lastName": "Joules"
}
See the audit logs in the server's console output:
[audit-log] - PersonalDataModified: {
data_subject: {
id: { ID: '1004155' },
role: 'Customer',
type: 'AdminService.Customers'
},
object: {
type: 'AdminService.Customers',
id: { ID: '1004155' }
},
attributes: [
{ name: 'firstName', old: 'Daniel', new: 'Danny' },
{ name: 'lastName', old: 'Watts', new: 'Joules' }
],
uuid: '71fa93d9-c993-405f-ba1b-a9ef42668199',
tenant: 't1',
user: 'alice',
time: 2023-02-26T08:13:48.287Z
}
In Production
The end-to-end out-of-the-box functionality provided by this plugin requires a paid-for instance of the SAP Audit Log service for customers. However, it is possible to provide an own implementation that writes the audit logs to a custom store.
Learn more about using the SAP Audit Log service.
Learn more about custom audit logging.
Support, Feedback, Contributing
This project is open to feature requests/suggestions, bug reports etc. via GitHub issues. Contribution and feedback are encouraged and always welcome. For more information about how to contribute, the project structure, as well as additional contribution information, see our Contribution Guidelines.
Code of Conduct
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone. By participating in this project, you agree to abide by its Code of Conduct at all times.
Licensing
Copyright 2023 SAP SE or an SAP affiliate company and contributors. Please see our LICENSE for copyright and license information. Detailed information including third-party components and their licensing/copyright information is available via the REUSE tool.
History
Removed 1
Notes
Removed
- Dropped CDS 8 support; minimum supported version is now
@sap/cds@>=9
Fixes 2
Notes
Fixed
- Properly encode request body parameters using in audit-log-to-restv2
- Resolved server crash when
@PersonalDataannotations are applied to composition targets whose DataSubject is only reachable via the parent entity's sibling association
Fixes 2
Notes
Fixed
- Updated the audit log service plan detection logic to support the new URL format
- The absence of
req.targetdoes not lead to an error
Changed 3
Notes
Changed
- Adjusted auto-detection of kind
audit-log-to-alsto now check for a VCAP service name matching "auditlog-ng" - Adjusted how the handlers for emitting audit logs are registered to support feature toggle and extensibility scenarios.
- Improved debug logging in cases where emitting audit log fails
- Adjusted auto-detection of kind
Features 1, Fixes 1
Notes
Added
audit-log-to-alsng: Support for sending generic audit log events
Fixed
audit-log-to-alsng: Correctly retrieveappIdfrom theVCAP_APPLICATIONenvironment variable
Fixes 1
Notes
Fixed
audit-log-to-alsng: EventDataPayload to Support Multi-Key Object and DataSubject IDs
Features 1
Notes
Added
- Beta support for next generation SAP Audit Log Service
- Use explicit kind
audit-log-to-alsngor alpha auto-detect kindaudit-log-to-als
- Use explicit kind
- Beta support for next generation SAP Audit Log Service
Fixes 3
Notes
Fixed
- Erroneous modification log for non-updated key properties
- Error during non-modifying queries on database level
- Specify charset UTF-8 for requests to SAP Audit Log Service
Fixes 2
Notes
Fixed
- Support for
@sap/cds^8.2 - Reduce clutter in error raised for outbound requests
- Support for
Features 1, Changed 1
Notes
Added
- Allow to specify undefined tenant in order to log to provider account in multi-tenant scenarios
Changed
- Use kind
audit-log-to-restv2in profilehybrid
Features 1, Fixes 2
Notes
Added
- Support for
@sap/cds^7.5
Fixed
- Automatic personal data modification logging for data subject details with renamed keys
- Data subject resolution in circular models
- Support for
Fixes 1
Notes
Fixed
- Automatic personal data modification logging for deep data structures with renamings
Fixes 1
Notes
Fixed
- Falsy early exit during bootstrapping in case a service does not contain personal data
Features 1
Notes
Added
- Common log entry fields
uuid,tenant,userandtimecan be provided manually
- Common log entry fields
Features 3, Changed 1, Fixes 1
Notes
Added
- Support for Premium plan of SAP Audit Log Service
- Support for XSUAA credential type
x509 - Support for generic outbox
Changed
- Always use outbox (as configured in project)
Fixed
- Avoid dangling
SELECTs to resolve data subject IDs, which resulted in "Transaction already closed" errors
Fixes 1
Notes
Fixed
- If the request has no tenant (e.g., Unauthorized), the audit log shall be sent to the provider account
Fixes 2
Notes
Fixed
- Defaulting of
@PersonalData.DataSubjectRoleto entity name - Overriding service configuration
- Defaulting of
Changed 1
Notes
Changed
- Default value for
cds.requires['audit-log'].handlechanged to['READ', 'WRITE'], i.e., accessing sensitive data is now logged by default.
- Default value for
Features 1
Notes
Added
- Export class
AuditLogServicefor extending in custom implementations as follows:const { AuditLogService } = require('@cap-js/audit-logging') class MyAuditLogService extends AuditLogService { async init() { [...] // call AuditLogService's init await super.init() } } module.exports = MyAuditLogService
- Export class
Removed 3, Features 4, Changed 2, Fixes 1
Notes
Added
- New API:
await audit.log('<event>', <data>)for asynchronous logs (cf.emit)await audit.logSync('<event>', <data>)for synchronous logs (cf.send)
- New REST API-based schema with auto-filled
LogEntryaspect - New events
SensitiveDataRead,PersonalDataModified,ConfigurationModified, andSecurityEvent - Full support for OAuth2 plan of SAP Audit Log Service
Changed
- Whether reading sensitive data and modifying personal data is logged is determined by
cds.requires['audit-log'].handle: [...]. Possible values in the array areREADand/ orWRITE, withWRITEas the sole default entry. Hence, accessing sensitive data is not logged by default. - Integration with SAP Audit Log Service via REST API instead of client library (
@sap/audit-logging)
Fixed
- Various glitches in log calculation
Removed
- Old events
dataAccessLog,dataModificationLog,configChangeLog, andsecurityLog @AuditLog.Operationannotations are ignored. Having the plugin as dependency signals the intent to audit log.cds.features.audit_personal_data: trueis no longer necessary. Instead, simply add the plugin as a dependency.
- New API:
Others providing
- ABAP-LoggerABAP-LoggerA logging library for ABAP that records messages into the standard Application Log (BC-SRV-BAL) and displays them from there, installed through abapGit on ABAP 702 or higher.independent, abapLogging library for ABAP over the Application Logfrom ABAP
- abap-log-exporterabap-log-exporterExports SAP NetWeaver logs from the Business Application Log to an external log system such as Graylog or Loki, converting entries to GELF or Loki format through a separately configured reader, converter and connector.independent, abapExports Business Application Log entries to Graylog or Lokifrom ABAP
- ABAP-PRCABAP-PRCA framework for custom multi-step ABAP processes: a process class declares the states, and the framework runs each document through them and monitors the run.independent, abapFramework for multi-step ABAP processes with monitoringfrom ABAP
- SAP Application Logging service for SAP BTPSAP Application Logging service for SAP BTPCollects an application's log lines from Cloud Foundry or Kyma into a searchable Kibana, for the retention the plan sets.sap official, btpCollects Cloud Foundry or Kyma logs into a searchable Kibanafrom BTP/BAIP
- SAP Cloud LoggingSAP Cloud LoggingAn instance-based observability service built on OpenSearch that stores and analyses logs, metrics and traces from Cloud Foundry, Kyma, Kubernetes and other runtime environments.sap official, btpOpenSearch-based store for logs, metrics and tracesfrom BTP/BAIP
- com.sap.cds:cds-services-bomcom.sap.cds:cds-services-bomThe Maven bill of materials for CAP Java, pinning every com.sap.cds module in a release, from the API and core runtime to the Spring Boot starters and the CQN engine, to the same version.sap official, capMaven bill of materials pinning CAP Java module versionsfrom CAP
- abap-logabap-logA logging library for ABAP with one logger interface in front of several targets, from the Application Log and the job log to database tables, files and the Eclipse console.independent, abapABAP logging library with one interface across output targetsfrom ABAP
- ABAP_LOGGINGABAP_LOGGINGAn object-oriented wrapper around SAP's Business Application Log (BAL) for ABAP NetWeaver, chaining texts, messages and exceptions onto a log header that persists in its own or the same connection.independent, abapObject-oriented wrapper around the Business Application Logfrom ABAP
- abap-cloud-loggerabap-cloud-loggerA logging library for ABAP Cloud that wraps the released class CL_BALI_LOG in a chainable logger, collecting exceptions, messages and tables, with a stopwatch and a sticky context tag.independent, abapChainable logger for ABAP Cloud around CL_BALI_LOGfrom ABAP
- abap-fm-loggerabap-fm-loggerA logger for ABAP function modules (RFC) that stores each call's parameters as JSON in one table, with a viewer report to search the log and reprocess a record, akin to WE10 and WE19.independent, abapLogger storing RFC function module call parameters as JSONfrom ABAP
- openui5-error-collectoropenui5-error-collectorA UI5 library that collects a running app's JavaScript errors, unhandled Promise rejections and UI5 log events, and can post them to a backend with navigator.sendBeacon.independent, ui5UI5 library collecting an app's JavaScript errorsfrom UI5
- open-abap-balopen-abap-balApplication logging for ABAP code transpiled to JavaScript and run on Node.js, one of the runtime libraries open-abap.org lists.community org, abapApplication logging for ABAP transpiled to JavaScript on Node.jsfrom ABAP
- @openui5/sap.ui.core@openui5/sap.ui.coreThe OpenUI5 core: the module loader, the MVC runtime, data binding, routing, theming and the test stack, which is everything a UI5 app does before a single community package is added.sap official, ui5Framework core: module loader, MVC runtime, binding, routing, themingfrom UI5
- abap-fluentdabap-fluentdA Fluentd client written in ABAP for sending log lines from an ABAP system to a Fluentd collector, where entries are flushed with an explicit COMMIT WORK.independent, abapFluentd client in ABAP for sending log lines to a collectorfrom ABAP
- @saptools/cf-logs@saptools/cf-logsA command line and typed Node.js library that fetches and streams the logs of one Cloud Foundry app and parses them into structured rows.independent, btpLog fetcher and parser for one Cloud Foundry appfrom BTP/BAIP
- @saptools/cf-tail@saptools/cf-tailA command line that tails every started app in a Cloud Foundry space at once and merges their logs into one timeline by timestamp, with filters by level, tenant, router status and time window.independent, btpMerged log tail of every started app in a Cloud Foundry spacefrom BTP/BAIP
- sap-usi-logging-apisap-usi-logging-apiAn object-oriented encapsulation around SAP's Application Log (transaction SLG1), controlled by customizing, with attachable data containers that SLG1 shows behind a detail button.independent, abapObject-oriented wrapper around SAP's Application Log (SLG1)from ABAP
- srbjsloggersrbjsloggerA browser JavaScript logger whose log, warn and error calls write prominent output to the console, loaded into a UI5 app through index.html or the manifest's resources.independent, ui5A browser JavaScript logger whose log, warn and error calls write prominent output to the console, loaded into a UI5 app through index.html or the manifest's resources.from UI5
- abap-message-loggerabap-message-loggerA message logger for ABAP Cloud that collects T100 messages, BAPIRET2 structures, exceptions and plain text before saving them to the Application Log.independent, abapMessage logger for ABAP Cloud that saves to the Application Logfrom ABAP
- SAP Audit Log serviceSAP Audit Log serviceIngests compliance audit data from BTP services and applications and keeps it for ninety days by default; retrieval and longer retention are separate services.sap official, btpIngests and retains compliance audit data from BTPfrom BTP/BAIP
- com.sap.cds:cds-feature-auditlog-ngcom.sap.cds:cds-feature-auditlog-ngA CAP Java plugin that sends audit log events to the SAP Audit Log service in the format the Audit Log Event Catalog expects.sap official, capCAP Java plugin sending audit log events to SAP Audit Log servicefrom CAP
- com.sap.cds:cds-feature-auditlog-v2com.sap.cds:cds-feature-auditlog-v2The CAP Java handler that sends the SDK's AuditLog events to the SAP Audit Log service over its API version 2, once a service binding is present.sap official, capCAP Java handler for SAP Audit Log service API version 2from CAP
- com.sap.cds:cds-services-bomcom.sap.cds:cds-services-bomThe Maven bill of materials for CAP Java, pinning every com.sap.cds module in a release, from the API and core runtime to the Spring Boot starters and the CQN engine, to the same version.sap official, capMaven bill of materials pinning CAP Java module versionsfrom CAP
- s4hana-hana-audit-policiess4hana-hana-audit-policiesSQL templates for the SAP HANA audit policies of the database tenant an SAP S/4HANA system uses, in four sets from the mandatory default policies to scenario examples.sap official, btpSQL templates for HANA audit policies of an S/4HANA tenantfrom BTP/BAIP
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
Flavors
“npm add @cap-js/audit-logging” — cap-js/audit-logging — README
Contributors
Show 1 more
History in the atlas
- The plugin's own integration is used; an own implementation may write the audit logs to a custom store instead.
- The plugin required the Audit Log service and said nothing of what passes between them.
- Integration with the SAP Audit Log service, so operations on personal data are recorded in the form an auditor expects without the application writing the entries.
- First seen.
For your agent
- Ref
artifact:cap-js-audit-logging- JSON
- /artifacts/cap-js-audit-logging.json
- MCP
- Connecting an agent