ATG Logging Tips Few things to know before start Logging

Always provide meaningful information in log messages
Think in the direction how logging will help
to solve an issue or report a status later stage in maintaining
the application.This will inspire to add value while putting
logging in your code.

Its advisable,while logging include the name of the method,session ids,this will help to easily identify which portion of code issue is and allow log entries to track back what user is doing to end up in an issue.

Always use if statements before you actually write the logging
code,refer the below example for this,otherwise you will end up
logging everything which will have a serious impact on performance.

This is good

if(isLoggingDebug()) logDebug(“handleAddItemsToOrder() Executing Add Item To Order for session “ + getSessionId() + “ for product “ + getProductId());

This is bad

if(isLoggingDebug()) logDebug(“ handleAddItemsToOrder() “Hello World”);

Do not use two lines of logging when one would do,because in
actual production there will be many threads running
through the code and your log statement will be written to the
logs many times in a minute.

Logging Debug must set to false by default.Because this level is used to log the granular information of a method or an operation, its advised to turn this on only in development environment.In rare scenarios this will be turned on in live to identify a root cause most cases to identify performance related issues.

Logging Info is used to indicate the startup and initialisation of global components,you might have noticed the info level messages coming up in the server console during the application server startup.

Logging Error is used in situation where a system error occurs and due to that user is not able to proceed further,one scenario would be an external system down and request getting timed out.

customize your log files to include timestamp,session id etc.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...