Skip to content

Create a logger

Jörg Neumann edited this page Jan 31, 2022 · 4 revisions

The first step is to call the central factory in order to create the logger.

DATA(logger) = /usi/cl_bal_factory=>get_instance( )->create_new_logger( i_log_object  = 'ZMY_REPORT'
                                                                        i_sub_object  = 'DELETE_USER'
                                                                        i_external_id = i_username ).

Parameters

Name Mandatory? Description
i_log_object yes Log object
i_sub_object Depends on
i_log_object
Subobject
i_external_id no Should be used whenever possible to make searching for logs easier.

Should be the technical ID of the processed object.

Log object and sub object are defined in transaction SLG0.

Log objects may or may not have subobjects - this is up to the person customizing them. But there is a catch, one needs to know: If a log object has subobjects, using them becomes MANDATORY!

Regular behavior

The factory is implementing a singleton pattern and will only allow one log writer at a time (see: Central Concepts -> One Log). It will keep that one instance until its owner explicitly destroys it. Subsequent calls to the factory will return that singleton instance even if a log writer for a totally different log object was requested.

Error handling

Passing an invalid combination of log object and subobject will make the factory use a valid fallback instead. The logger will still be created but with a different combination of log object and subobject. If you cannot find your log check the troubleshooting guide (see: (Troubleshooting -> Log cannot be found).

You might also want to check the log levels for both: the passed combination and the fallback.

Clone this wiki locally