Author: Sheetal Gangele
As a user interface(UI) developer ,apart from regular coding and designing of UI some standard tasks also need to be taken care . For example some standards like globalization(Translatability),Accessibility(tab order etc.) also logging and tracing which is not only a standard but will help a developer and administrator to understand the control flow apart from comments . In this blog I will tell you not the general practice but some steps which will help you to find out the minimum places where logging and tracing needs to be done.
Firstly Some basics for logging tracing which is a prerequisite to know before starting.
Logs and traces are two manners of protocolling the events of your J2EE System. Logs are usually addressed to an administrator of a customer system. All significant events that occur on a cluster node of the J2EE Cluster are written to log files.Traces show the details of the control flow - they are watched by developers and the support organization. During normal operation developers and supporters are not looking on a running system. On the other hand the administrator has to check the system regularly.
- records normal or exceptional events
- switched on during normal operation
- log messages are emitted to categories which describe distinguished problem areas such as database problems or security auditing
- log messages are also visible in the trace
- reconstruction of the control flow of a running application
- used during development or problem detection in productive systems (alternative to debugging)
- trace messages are emitted to locations which describe delimited code areas such as packages or classes
The content of a message must be carefully designed with respect to the addressees and the message type (trace or log message) chosen.
- Trace messages are intended for persons with development skills and a deep understanding of the application
- log messages are intended for a much broader audience with different skills and backgrounds.
Points to keep in mind:-
- An important part of any log and trace message is its severity. This denotes the level of importance or relevance of a certain message
- The logging API provides these severities: DEBUG, PATH, INFO, WARNING, ERROR, FATAL
- Categories and locations are associated with a severity. This acts as filter where only those messages that are of equal or higher severity may pass
- Another important aspect of the logging API is destinations
- This refers to where messages are actually written to (e.g. files, console, database)
- Severity and destination make up the configuration of a location and category
To know more you can follow the links given at the end.
In Web Dynpro framework a default tracer with the name logger is there always. So we can use it directly.For logging we have to define in begin others tab.
Private static final com.sap.tc.logging.Category realLogger =
com.sap.tc.logging.Category.getCategory (Category. APPLICATIONS, "/<Location name >/<Application>");
Tracing: (Considering there is two different DC hierarchy for Model importing and other Dc will have just views.)
1. Find out all service calls and execute method in Model DC Comp Controller.
2. In UI DC Find out all the places (Actions,WDInit,Events,Methods,Private Classes etc) where try/catch block is there.
1.Find out all catch blocks and there try to catch the exception in the logger itself.
I can't say that this is best practice to do,But these are the places where you need to follow logging/tracing.For refrences and to look into other methods in API you can read javadoc's link is provided
2.Logging and tracing API in javadoc: