abap-message-logger
A message logger for ABAP Cloud that collects T100 messages, BAPIRET2 structures, exceptions and plain text before saving them to the Application Log.
A logger class for the most use-cases in ABAP Cloud, focused on collecting messages and saving them to the Application Log. It accepts a T100 message, a BAPIRET2 structure or table, a caught exception including stacked ones, or a plain text string, and can build its instance through a factory or reuse one through a singleton. Support for RAP exceptions and a second database connection are included; context data is listed as planned rather than shipped. It runs on ABAP EnvironmentSAP BTP ABAP environmentSAP's ABAP runtime on BTP: ABAP systems developed in the ABAP Cloud model on SAP HANA Cloud, for cloud apps, OData services and side-by-side extensions of SAP S/4HANA.sap official, btp, Public Cloud and Private Cloud S/4HANA 2023 and later.
Facts
Where it sits
Who is behind it
In the atlas: maintains 7, contributes to 8@Xexermaintainer
What it declares
Every artifact
- Type
- Package
- Origin
- Independently maintained
As a package
- Where it runs
- does not say
- Distributed through
- does not say
Connections
Seeing what a running service did, in a readable form
Download
README
quoted from Xexer/abap-message-logger under MIT, readMessage Logger for ABAP Cloud (AML)
A logger class for the most use-cases in ABAP Cloud. Focus is the logging of messages and types with the posibility to save the log to the Application Logs.
ABAP Cloud
Support of ABAP Cloud (ABAP Environment, Public Cloud and Private Cloud S/4HANA 2023+) with key capabilities:
- Mock- and testable
- Configuration via Settings
- Factory for Creation and/or Singleton
- Support for Application Job, 2nd DB Connection
- Support for RAP exceptions
- Context data [Planned]
Configuration
You can configure the log during the creation. Here are the different settings explained. All settions and fields are optional.
| Field | Description |
|---|---|
| object | Application Log - Object |
| subobject | Application Log - Subobject |
| external_id | Application Log - External ID |
| default_message_class | Default message class (add_message) |
| default_message_type | Default message_type (add_message, text and exception); Default E |
| no_stacked_exceptions | Only the top exception is extracted |
| save_with_job | Save the log with the Application Job |
| use_2nd_db_connection | Use the 2nd connection to save log (Works with rollback work) |
| emergency_logging | The messages are logged immediately, but performance is not particularly good. Saving is not necessary. |
| configuration | Configuration object for archive settings |
You can create your own configuration, if you want to overwrite archive settings from ZCL_AML_DEFAULT_CONFIG.
Methods
Methods to add messages to the object:
| Method | Description |
|---|---|
| add_message | T100 message |
| add_message_bapi | BAPIRET2 structure |
| add_message_bapis | BAPIRET2 table |
| add_message_exception | Any exception (also stacked) |
| add_message_system | System variables (SY) |
| add_message_text | Generic text or string |
| add_message_xco | Single XCO message |
| add_message_xcos | XCO message container |
Methods to get the collected messages:
| Method | Description |
|---|---|
| get_messages | Internal Format (UTC Timestamp, Type, SYMSG, BALI object) |
| get_messages_bapi | BAPIRET2 table |
| get_messages_flat | String table |
| get_messages_rap | Exceptions with interface IF_ABAP_BEHV_MESSAGE |
| get_messages_xco | XCO message container |
Methods that help to get more informations:
| Method | Description |
|---|---|
| get_number_of_messages | Returns the number of collected messages |
| has_error | Check the messages for Error (AEX) |
| has_warning | Check the messages for Warnings (WAEX) |
| merge_logs | Merge another log into this one |
| save | Save messages to application log |
| search_message | Search for a message in the log |
Unit Tests
The framework is tested using unit tests, and currently all components are covered. If errors or enhancements are made, we would expand the unit tests.
Usage
Here you get some informations, how to use the log. You could also check the Unit Tests for message handling.
Creation
The normal creation of a log object.
DATA(log) = zcl_aml_log_factory=>create( ).
When you want to set some settings in the class, manage them via the constructor.
DATA(log) = zcl_aml_log_factory=>create( VALUE #( default_message_class = 'Z_AML'
default_message_type = 'I' ) ).
If you want to reuse the log or havn't saved it, you can use the Singleton principle. You can get the DEFAULT log or create different versions with the identification.
DATA(log) = zcl_aml_log_factory=>get_instance( ).
Messages
Add messages via the different methods. Here to add a simple T100 message:
log->add_message( '001' ).
... or if you have catched an exception:
CATCH cx_bali_runtime INTO DATA(bali_error).
log->add_message_exception( bali_error ).
ENDTRY.
Analysis
If you want to validate the erros, you could use the helper methods to check for errors.
IF log->has_error( ).
ENDIF
Save
To save the log you simple need to call the save method. Ensure that the settings
log->save( ).
Where-Used list
If you want to use the where-used list of messages without creating dummy variables each time and using pragmas for ATC and ABAP Cleaner, you can use the corresponding variable in the log directly in your code before logging the message.
MESSAGE s005(z_aml) INTO log->message_text.
log->add_message_system( ).
Error
The framework catch possible exceptions and wrapps it in a NO_CHECK exception ZCX_AML_ERROR. For example if you want to save the log and an instance is not created, the exception could be raised.
Others providing
Compare all 20 on the Logging page →- 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
- @cap-js/audit-logging@cap-js/audit-loggingIntegration 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.sap official, capCAP integration with the SAP Audit Log servicefrom 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
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
abaplint
Flavors
“Support of ABAP Cloud (ABAP Environment, Public Cloud and Private Cloud S/4HANA 2023+)” — Xexer/abap-message-logger — README
History in the atlas
- First seen.
For your agent
- Ref
artifact:xexer-abap-message-logger- JSON
- /artifacts/xexer-abap-message-logger.json
- MCP
- Connecting an agent