Show TOC Start of Content Area

Background documentation Tips and Tricks  Locate the document in its SAP Library structure

      What if the content of the properties file is invalid?

Normally, if the syntax or semantics is incorrect, or if there is simply a spelling mistake, the configuration fails on that definition and prompts an error message (in such cases the default settings may be taken). The tool will continue to evaluate the subsequent configuration and output messages accordingly, based on whatever successful configuration that has been made.

The behavior results from the SAP Logging API error handling mechanism. For more information, see Administrative Issues.

      Is there an automatic lookup of default properties file?

There is no system property to define this, nor there is a default physical file location specified for this. It is necessary to make one call in the program to load the properties.

      Is there a possibility to define a Location and/or Category object in the file?

It is not necessary to create and maintain a category or a location object. These objects are always accessible by making calls, such as Category.getCategory() and Location.getLocation(), and the rest is done by the logging framework. It is a good practice to use a static variable to store the handle for better performance in case the source objects have to be accessed frequently. Thus, it is not necessary to define/create these source objects explicitly in the configuration file in advance. Use it directly in your program.

Note

However, when you are specifying certain properties for a source object in the configuration file, for example, assigning severity or logs to a location or category, the corresponding location or category is implicitly instantiated and correctly configured.

      Does the order of configuration matter?

In general, no. Not for class variable definition. Consider the following:

This graphic is explained in the accompanying text

com.sapmarkets.foo.logs       = + log[Console], log[File]

log[Console]                  = ConsoleLog

log[Console].formatter        = ListFormatter

log[File]                     = FileLog

log[File].pattern             = %t/trace.log

log[File].formatter           = formatter[Trace]

formatter[Trace]              = TraceFormatter

formatter[Trace].pattern      = %s: %24d: %m

 

The order of severity assignment is not affected. The severity inheritance is controlled by the closest ancestor who has an explicitly assigned severity.

This graphic is explained in the accompanying text

com.sapmarkets.foo.fooChild.severity   = INFO

com.sapmarkets.foo.severity            = WARNING

 

If there are further descendants of com.sapmarkets.foo.fooChild that do not have an explicit severity assignment, they inherit the severity from com.sapmarkets.foo.fooChild.

For other straightforward assignment types the order does matter. Apparently, the latter assignment wins:

This graphic is explained in the accompanying text

log[Console]            = ConsoleLog

log[Console].formatter  = ListFormatter

log[Console].formatter  = XMLFormatter

 

      What will be the output format shown in the console?

The use of a ‘+’ sign does not apply to log assignments specified in the current file configuration content (it affects the existing assigned logs, such as from the previous round of configuration in the case of periodic configuration). Therefore, the sequence is important and the FileLog wins (assuming no previous configuration has been done). For more information, see Syntax and Semantics of the Properties File.

This graphic is explained in the accompanying text

com.sapmarkets.foo.logs = + ConsoleLog

com.sapmarkets.foo.logs = + FileLog

 

If you want to assign multiple logs, use a comma as a delimiter:

This graphic is explained in the accompanying text

com.sapmarkets.foo.logs = + ConsoleLog, FileLog

 

End of Content Area