Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos
class="sapTxtSml" style="font-weight: normal;">

After couple of days of fiddling around, API browsing and reading documentation I was able to understand how the log-configuration.xml file enabled developers to specify various logging parameters at design time and how log configurator enabled at run time to manage log levels.

This web log is an attempt to answer some of the questions from the WebDynpro forum and also an easy pickup point to enable logging within WebDynpro applications. This web log is not tutorial a on how the logging apis work but a description of the available tools and services with in the Web AS that allows for easy management of the logging framework.

Different logging requirements for an application

As far I see it the stakeholders for logged data from an application would be a 1) developer 2) System Administrator and 3) Application support personnel. The log data in question here is typically from a business application in production. What differentiates these people is the kind of the data that each of them would want to view and the different conditions under which they would want to view it. Some of the possible scenarios are.

  • Resource usage such as memory or connection management details at peak loads by System administrator
  • Application tracing (methods called, events fired, exceptions raised) to debug an error condition experienced by an end user by a Developer
  • Application support personnel in tandem with the Developer to answer why a functional aspect of the application differs in behaviour under certain contexts.

Applying the above requirements to an application:

Say the primary class that is connected to database connection management is com.sdn.trial.wd.dbpool.ConnectionHandlerCust and the core class that is involved in a business process is com.sdn.trial.wd.orders.PurchaseOrderProcess

The requirement is to log runtime connection pooling details into a separate file sdnconnectionusg.trc and source purchase order creation details into the general application log used by the system sdnapplications.log.

class="sapTxtSml" style="font-weight: normal;">
Log Formatter

Create the log-configuration.xml file by right clicking the WebDynpro development component and choosing the option create ‘Create Log Configuration file’ (The log-configuation.xml can be configured for one development component but the settings can be made applicable to other DCs as well) .

The first tab is the Log Formatter tab that allows you to specify the format in which the data should be logged; in this case we would like to see the location from where the message originated, the message severity and the time stamp. The placeholders %l %d %s and %m specify these.

We also choose the Trace formatter as the log type.

class="sapTxtSml" style="font-weight: normal;"> Log Destination

The next tab is the log destinations tab, the parameters here configures the destination in terms of the file name ,location , type of log and various other parameters such as file size limit and count.

The key thing here is that two destinations have been created so that application can use both of these depending on what needs to be logged. However both the destinations have the same formatter since the requirement is limited to having same format for both the logs.

class="sapTxtSml" style="font-weight: normal;"> Log Controller and Categories

The log controller name has been described as com.sdn.trial.wd, by doing this logging is attached to this level of package and any class that resides on the same level of package or below inherits the log properties of the controller.

Thus the logger object created by the WebDynpro code generation for classes com.sdn.trial.wd.dbpool.ConnectionHandlerCust and com.sdn.trial.wd.orders.PurchaseOrderProcess will inherit the properties of the log controller com.sdn.trial.wd. Two categories have also been defined /Applications/MyApp and /System/MyApp, since the requirement is to log into different files, the categories here have been attached with the destinations sdn.log.dest.applications and sdn.log.dest.system respectively

The difference between a location and category is that while a Location is used to denote the source code area from where the error occurred, Categories are used denote the functional area from where the error occurred.

Thus the overall definition here defines that: Capture all logs from classes that fall in the package hierarchy com.sdn.trial.wd and from functional areas that relate to Applications and System.

class="sapTxtSml" style="font-weight: normal;"> Implementation

Category = Category.getCategory(Category.APPLICATIONS,MyApp);
logger.infoT(cat,"Created Purchase order 3000245");
for
com.sdn.trial.wd.orders.PurchaseOrderProcess

Category cat = Category.getCategory(Category.SYSTEM,MyApp);
logger.infoT(cat,"Connection pool size = 10");
for
com.sdn.trial.wd.dbpool.ConnectionHandlerCust

Here we have programmatically defined that logs emanating from the class PurchaseOrderProcess is of the category /APPLICATIONS/MyApp and logs from class ConnectionHandlerCust is of the category /SYSTEM/MyApp
class="sapTxtSml" style="font-weight: normal;">

Further Administration:

After deployment of the WebDynpro application into WAS. The controllers, destinations, categories and formatters defined via the log-configuration.xml are also available for changes through the log configurator service. This is accessible via the Visual Administrator through

Server-> Services -> Log Configurator. Switching to advanced mode helps to access all the services.It allows you at runtime change all the parameter values defined at design time

class="sapTxtSml" style="font-weight: normal;"> Sample Output:

Expected log output for the above configuration would be

com.sdn.trial.wd.dbpool.ConnectionHandlerCust Nov 9, 2004 6:10:07 PM Info Connection pool size = 10

and

com.sdn.trial.wd.orders.PurchaseOrderProcess Nov 9, 2004 6:15:25 PM Info Created Purchase order 3000245

More info on logging in WAS applications can be found in this document , Concepts such as severities,inheritance thresholds etc are explained in detail.
2 Comments