PackagePackagetypeA library you install and call yourself.See every one →What this type is →independently maintainedindependently maintainedoriginPublished by one person or a small company outside SAP. Says nothing about quality; the readings say that.See every one →

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 Environment, Public Cloud and Private Cloud S/4HANA 2023 and later.

Facts

Last pushLicenceMIT

Where it sits

Lives in
Provides
LoggingABAPLoggingcapabilitySeeing what a running service did, in a form something can read afterwards — levels, a formatter that suits a laptop and one that suits a log service.
Flavors

Who is behind it

XexerXexerPersonMaintains this
In the atlas: maintains 7, contributes to 8
@Xexer
maintainer

What it declares

Every artifact

Type
Package
Origin
Independently maintained

As a package

Where it runs
does not say
Distributed through
does not say

Connections1

README

quoted from Xexer/abap-message-logger under MIT, read
Xexer/abap-message-logger/README.mdOn GitHub

Message 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.

FieldDescription
objectApplication Log - Object
subobjectApplication Log - Subobject
external_idApplication Log - External ID
default_message_classDefault message class (add_message)
default_message_typeDefault message_type (add_message, text and exception); Default E
no_stacked_exceptionsOnly the top exception is extracted
save_with_jobSave the log with the Application Job
use_2nd_db_connectionUse the 2nd connection to save log (Works with rollback work)
emergency_loggingThe messages are logged immediately, but performance is not particularly good. Saving is not necessary.
configurationConfiguration 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:

MethodDescription
add_messageT100 message
add_message_bapiBAPIRET2 structure
add_message_bapisBAPIRET2 table
add_message_exceptionAny exception (also stacked)
add_message_systemSystem variables (SY)
add_message_textGeneric text or string
add_message_xcoSingle XCO message
add_message_xcosXCO message container

Methods to get the collected messages:

MethodDescription
get_messagesInternal Format (UTC Timestamp, Type, SYMSG, BALI object)
get_messages_bapiBAPIRET2 table
get_messages_flatString table
get_messages_rapExceptions with interface IF_ABAP_BEHV_MESSAGE
get_messages_xcoXCO message container

Methods that help to get more informations:

MethodDescription
get_number_of_messagesReturns the number of collected messages
has_errorCheck the messages for Error (AEX)
has_warningCheck the messages for Warnings (WAEX)
merge_logsMerge another log into this one
saveSave messages to application log
search_messageSearch 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.

MIT, read
Logging
  1. ABAP-LoggerLogging library for ABAP over the Application Log
  2. abap-log-exporterExports Business Application Log entries to Graylog or Loki
  3. ABAP-PRCFramework for multi-step ABAP processes with monitoring
  4. abap-logABAP logging library with one interface across output targets
  5. ABAP_LOGGINGObject-oriented wrapper around the Business Application Log
  6. abap-cloud-loggerChainable logger for ABAP Cloud around CL_BALI_LOG
  7. abap-fm-loggerLogger storing RFC function module call parameters as JSON
  8. open-abap-balApplication logging for ABAP transpiled to JavaScript on Node.js
  9. abap-fluentdFluentd client in ABAP for sending log lines to a collector
  10. sap-usi-logging-apiObject-oriented wrapper around SAP's Application Log (SLG1)

Details

Sources3
dotabapdiscovered herechecked
github.com/Xexer/abap-message-loggertree, pushes, contributors, CIchecked
README.mdquoted, and what the entry declareschecked

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
discovered viadotabap
first seen in the atlas
ecosystem and domainabap, operations-and-runtime
abaplint
issues under its own abaplint configuration227
lines1,399
statements785
objects12
files20
analysed, main
abaplint version2.120.84
Flavors1
ABAP Cloud
“Support of ABAP Cloud (ABAP Environment, Public Cloud and Private Cloud S/4HANA 2023+)” — Xexer/abap-message-logger — READMEchecked
History in the atlas1
  1. First seen.
For your agent
Ref
artifact:xexer-abap-message-logger
JSON
/artifacts/xexer-abap-message-logger.json
MCP
Connecting an agent