The Web Dynpro runtime environment and the Web Dynpro runtime services use the SAP Java Logging API for logging and tracing. The SAP Java Logging API consists of two main classes:
· Category – used for logging
· Location – used for tracing
Logging supports messages that are created, during the regular run of a Web application, to record events. Tracing is used for reproducing the control flow of a running Web application.
You can configure the logging within Web Dynpro using the logging.properties file. For example, you can configure:
· The trace level you use
· The prefix of the package for which the log is to be created
· The name of the log file you use
· The location of the log file you use
Web Dynpro provides two types of logging.properties files.
· The logging.properties file that is known as the standard configuration file. It refers to the Web Dynpro runtime environment. The settings of the standard configuration file are used for the standard configuration of logging and tracing.
· A logging.properties file that you can provide optionally for the Web Dynpro application.
If you use the SAP Java Logging API, exactly one set of configuration parameters is available for each user of this API. In Web Dynpro, this means that the standard configuration file for logging is loaded at the start of the SAP J2EE Engine – that is, when the Web Dynpro runtime environment is already available. The standard configuration file specifies the initial values of the configuration parameters of the logging.
If the Web Dynpro application specifies its own logging.properties file, the values of the application-specific logging.propertiesfile overwrite the values that are set by the current logging.properties file. This file is loaded with the Web Dynpro runtime environment. The consequences are:
· If the logging.properties file of a Web Dynpro application contains an additional parameter, this parameter is added to the parameter set of the standard configuration file.
· If the logging.properties file of a Web Dynpro application contains a parameter that already exists in the current parameter set of the standard configuration file, this value is overwritten.
An application-specific logging.properties file can have unwanted effects on the logging of other Web Dynpro applications. Therefore, you should only set parameters that affect only the log classes that belong to the application.
If you import the application-specific logging.properties files using the SAP NetWeaver Developer Studio, refer to Importing Application-Specific Configuration File.
The following source code is the configuration of a standard configuration file logging.properties of the logging.
################################################
##
## Logging properties for the Web Dynpro Runtime.
##
################################################
################################################
##
## setup console log
##
################################################
log[Console] = ConsoleLog
log[Console].formatter = formatter[ConsoleFormat]
formatter[ConsoleFormat] = TraceFormatter
formatter[ConsoleFormat].pattern = [%-8s] [%-8t] %-40l: %m
################################################
##
## setup file log
##
################################################
log[File] = FileLog
log[File].pattern = WDR.log
#log[File].pattern = WDR.%g.log
## comment the next line in if the log file should be written to the system temp directory
#log[File].pattern = %t/WDR.%g.log
log[File].formatter = formatter[FileFormat]
log[File].limit = 10000000
#log[File].cnt = 5
formatter[FileFormat] = TraceFormatter
formatter[FileFormat].pattern = %24d [%-8s] [%-8t] %-40l: %m
################################################
##
## overwrite the default logging settings
##
################################################
com.sap.tc.webdynpro.logs = log[dummy]
log[dummy] = ConsoleLog
log[dummy].severity = NONE
################################################
##
## use the specified log file for all logging
## statements of Java classes with the packages
## starting with the specified prefix.
##
################################################
com.logs = log[File]
################################################
##
## set severity thresholds for certain
## subpackages
##
################################################
com.sap.tc.webdynpro.severity = ALL
com.sap.tc.webdynpro.services.session.WatchDog.severity = NONE
The following source code is the configuration of an application-specific standard configuration file logging.properties of the logging.
The logging of the application should be written in its own log file - the app_log.log file. If you want to store this file in the C:\temp directory, you should add the following lines to the content of the application-specific logging.properties file:
################################################
##
## setup app specific log file
##
################################################
log[APP_FILE] = FileLog
log[APP_FILE].pattern = C:\\temp\\app_log.log
log[APP_FILE].formatter = formatter[APP_FileFormat]
formatter[APP_FileFormat] = TraceFormatter
formatter[APP_FileFormat].pattern = %24d [%-8s] [%-8t] %-40l: %m
The application classes are contained in the common subpackage com.sap.app. If you want to create a log entry with a specific priority level for these classes only, you should add the following lines to the content of the application-specific logging.properties file:
################################################
##
## use the specified log file for all logging
## statements of Java classes with the packages
## starting with the specified prefix.
##
################################################
com.sap.app.logs
= log[APP_FILE]
com.sap.app.severity
= SEVERE