The use of the SAP standard functions for logging is a bit complex. Especially if you are used to log strings. The functions deployed by SAP are: BAL_LOG_MSG_ADD, BAL_LOG_CREATE, BAL_DB_SAVE, BAL_LOG_REFRESH
As i described in this articel – they all make the use of the character 50 fields MSGV1 to MSGV4 with it flaws. So this little utility class (download txt-logger-class) here makes use of the standard functions – to log things a bit more like in java.
The Logging can be monitored in the transaction SLG1. The Objects are like logging-categories. They can be maintained in SLG0.
*examples
" You can maintain your own objects in transaction SLG0 – create ZTEST
zcl_log=>info( msg = ‚msg msg msg msg 123 123 123 test‘ obj = ‚ZTEST‘).
zcl_log=>alert( msg = ‚msg msg msg msg 123 123 123 test‘ obj = ‚ZTEST‘).
zcl_log=>warning( msg = ‚msg msg msg msg 123 123 123 test‘ obj = ‚ZTEST‘).
zcl_log=>error( msg = ‚msg msg msg msg 123 123 123 test‘ obj = ‚ZTEST‘).
zcl_log=>save( ). "now control the transaction SLG1 with object ZTEST to see the test messages
I recommend to set the class for system wide use.
Kommentare
3 Antworten zu „ABAP: Logging – Logger“
Gosh. There is an error in the regex pattern.I will update the entry asap.
Hi, I tried to execute the given code. I too got the same error as ‘CX_SY_INVALID_REGEX’ at the Code part ‘FIND REGEX pattern IN nmsg SUBMATCHES s1. “for each 50/regex characters in regex’.
Could you please tell what is the reason and what should we do to make the code executable?
hi, just wanted to try it. I’m getting a Dump ‚CX_SY_INVALID_REGEX‘ at the Code part ‚FIND REGEX pattern IN nmsg SUBMATCHES s1. „for each 50/regex characters in regex‘.
I don’t know why. Is it possible to integrate subobjects with another name?
Cheers