Comments (4)
I would be interested to hear about anything you do in this respect. So far I am just barely dipping my toes, and have set up for one entity set logging (to application log) when a request does not process all the options (DONE-list does not match TODO-list) or an exception occurs - but I am only just getting started and sneak it in along with other changes.
However, it isn't clear to me whether you want to log the gateway exceptions or use the ABAP Logger as source for the messages returned with an exception.
I log the exceptions by catching the business and technical exceptions, adding them to the application log, and then re-raising the exception.
METHOD log_and_raise_gw_exception.
CHECK io_busi_exception IS BOUND AND io_busi_exception IS NOT INITIAL
OR io_tech_exception IS BOUND AND io_tech_exception IS NOT INITIAL.
DATA(lo_logger) = get_logger( ).
IF io_busi_exception IS BOUND AND io_busi_exception IS NOT INITIAL.
IF lo_logger IS BOUND.
lo_logger->e( io_busi_exception ).
lo_logger->save( ).
ENDIF.
RAISE EXCEPTION io_busi_exception.
ELSEIF io_tech_exception IS BOUND AND io_tech_exception IS NOT INITIAL.
IF lo_logger IS BOUND.
lo_logger->e( io_tech_exception ).
lo_logger->save( ).
ENDIF.
RAISE EXCEPTION io_tech_exception.
ENDIF.
ENDMETHOD.
In my query implementation
TRY.
set_logger( zcl_logger_factory=>create_log( object = '...'
subobject = '...'
desc = |OData query: ...|
auto_save = abap_true ) ).
get_..._handler( )->get_entityset( EXPORTING io_request = io_tech_request_context
IMPORTING es_response_context = es_response_context
et_entities = et_entityset
es_processing_todo = DATA(ls_requested_processing)
es_processing_done = DATA(ls_completed_processing) ).
IF ls_requested_processing <> ls_completed_processing.
IF get_logger( ) IS BOUND.
MESSAGE w020(zopu_bse) WITH ls_completed_processing ls_requested_processing INTO DATA(l_message).
get_logger( )->add( ).
ENDIF.
ENDIF.
CATCH /iwbep/cx_mgw_busi_exception INTO DATA(lo_busi_exception).
log_and_raise_gw_exception( io_busi_exception = lo_busi_exception ).
CATCH /iwbep/cx_mgw_tech_exception INTO DATA(lo_tech_exception).
log_and_raise_gw_exception( io_tech_exception = lo_tech_exception ).
ENDTRY.
Perhaps neither pretty or fancy, but I have to start somewhere :-)
from abap-logger.
There is no integration today. As you already pointed out, the backend implementation of an OData service is working with a special message container. The message container has methods to add free text messages, BAPI messages and other type of messages so in this point it is quite similar to the logger interface.
The difference is that the message container and its messages are sent to the OData client. Maybe you don't want that for all internal messages you write to application log.
One approach would be to support the message container type as input of the add() method of the logger interface and extract and log all messages it contains.
As SAP gateway components are available on all systems starting from 7.4, it would increase the requirements for this logger class.
Another approach is to have two calls where you need it: one for the message container, another for the logger. I think I would choose this one. The advantage is that you are more flexible and that the sequence of messages is correct. When you would log the complete message container (containing multiple messages) at the end of the OData method and you would have logged messages with the logger before, the sequence of message could get mixed up.
from abap-logger.
I see no problem with your approach. Just one hint: Errors raised by OData services are already written to the application log. Just run transaction /IWBEP/ERROR_LOG in your backend system and click on the button "Application Log". You can see that the error is written in the object /IWBEP, subobject RUNTIM.
from abap-logger.
Though I have no knowledge of the context, I'll take @andkopp to the word ("Errors raised by OData services are already written to the application log.") and consider this enhancement is not relevant.
Please reopen if I'm wrong.
from abap-logger.
Related Issues (20)
- "LV_CONTEXT" is not type-compatible with formal parameter "CONTEXT". HOT 2
- Redundant to SAP-Standard HOT 3
- Test classes use APPEND xxx TO yyy on sorted tables HOT 3
- bal_tt_msg type not exist HOT 1
- callback routine useless HOT 5
- adding syst messages no working for methods i,a,e,w,s of zcl_logger HOT 2
- Importance is not propagated when logging a table HOT 4
- Unit tests use non-existing SLG0 subobject HOT 5
- Limited Test Double Framework compatibility? HOT 2
- BAL-Log-Handle remains after destruction of ABAP-Logger HOT 1
- Misleading Name of Method popup() when providing custom Profile
- Build Hierarchy with Logger HOT 1
- Navigation to the application Log is not working for background jobs HOT 2
- Stale project? HOT 4
- Add support for BAPI_ALM_RETURN message structure HOT 1
- ABAP Logger v2 HOT 16
- Add injector class to match factory methods
- Add entry to log with context don't work if obj_to_log is an instance of a exception class
- Avoid abbreviations: add methods error, warning, info and success HOT 3
- Read messages from log with context HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abap-logger.