com.sap.tc.loggingStandard
Class PropertiesConfigurator13

java.lang.Object
  |
  +--com.sap.tc.logging.Configurator
        |
        +--com.sap.tc.loggingStandard.PropertiesConfigurator13

public class PropertiesConfigurator13
extends Configurator

This is based on com.sap.tc.logging.PropertiesConfigurator but with modified code to wrap around the configuration for JSR 47 API as in JDK 1.4. It is in the format of key-value pair, and the syntax rule follows that defined by SAP but with different semantics. In particular, it replaces the SAP terminology with the corresponding ones used in SUN 'java.util.logging', for the ease of use.

The syntax defined by SAP is similar to the default configuration file "lib/logging.properties" provided by SUN under the JRE directory, but it is even enhanced to support more flexible and clear definition, as shown in the example below.

In general, it is in the form of:
<Name>.<Attribute> = <Value>
You can learn more about the basic syntax concept described in PropertiesConfigurator. The specific syntax rule used in this wrapper class is listed after the example as well.

The concept of global handlers and level are not implemented in this wrapper, however, this can still be achieved, though with a slightly difference mechanism with the SAP logging tool. This can easily be specified in the configuration file, basically identical to the SUN syntax (shown in example below).
In addition to the global handler specification, you can specify local handler for each Logger class. Note that this is not mentioned/available in the SUN API.

Here is a simple example, followed by the syntax rule:

  .handlers = ConsoleHandler		#simulate global handlers, same syntax as in SUN

 					#simulate global severity level:
  .level = INFO			#everybody under this parent Logger will have threshold INFO.
  foo.parent.child1.level = WARNING 	#except all descendants of 'child1'


  #SAP syntax: allows configuration of this handler before assigning to the Logger
  handler[simpleFile]			= FileHandler
  handler[simpleFile].pattern		= C:\\temp\\result\\trace.txt
  handler[simpleFile].formatter 	= formatter[Simple]

  formatter[Simple]		= SimpleFormatter
  formatter[Simple].pattern	= %24d %-38l %s: %m		#this follows SAP style

  #Assign local handler for this Logger in addition to the global handler
  #Note that in this case, output to console will be done twice.
  foo.parent.child1.localHandlers =  handler[Console], handler[simpleFile]

 

Below shows the specific subset of the syntax of the properties definition used in this version:

<Configuration> = <Entry>*.
<Entry> = <Key> '=' <Value>
 
<Key> = [<Logger>] '.' <LoggerAttr>
|<Handler> ['.' <HandlerAttr>]
|<Formatter> ['.' <FormatterAttr>].
<Logger> = <Identifier> ('.' <Identifier>)*.
<LoggerAttr> = 'level'
|'handlers'
|'localHandlers'.
|'filters'.
<Handler> = 'handler' '[' <Identifier> ']'.
<HandlerAttr> = 'level'
|'formatter'
|'filters'
|'pattern'
|'limit'
|'cnt'.
<Formatter> = 'formatter' '[' <Identifier> ']'.
<FormatterAttr> = 'pattern'.
 
<Value> = <Level>
|<Objects>
|<String>
|<Identifier>.
<Level> = 'OFF' | 'SEVERE' |'WARNING' | 'INFO' | 'CONFIG' | 'FINE' | 'FINER' | 'FINEST'.
<Objects> = ['+'] <Object> (',' <Object>)*.
<Object> = <Class>
|<Handler>
|<Formatter>.
<Class> = 'FileHandler'
|'ConsoleHandler'
|'SimpleFormatter'
|'XMLFormatter'.
|<Identifier> ('.' <Identifier>)*.

Note: the order of the configuration does not matter in most cases,
except
severity assignment. This is due to the severity inheritance behavior described in the JSR47. Therefore, level settings for child nodes in the tree should come after settings for their parents.
Order of other assignments are ok, eg. you can assign a Handler 'vairable' to a Logger before you specify the configuration of the Handler itself. Refer to the example above that shows the configuration of the Formatter does come after its assignment to a FileHandler.

Options to specify pattern for both FileHandler(that is, filename) and the SimpleFormatter should refer to the Javadoc for the corresponding SAP classes: FileLog and TraceFormatter.

Limitation:
For the Handler object, only ConsoleHandler and FileHandler is supported in this wrapper.
For the Filter object, again, if users intend to implement any filters in this wrapper, this has to follow the interface of Filter, working on the LogRecord. Since this is most likely a filter class implemented by the user, so, assign the fully qualified classname as the value:

    handler[simpleFile].filters = com.sap.foo.FooFilter



Comparison:
This properties class is also compatible to the original SAP logging tool, in case users would like define configuration here with SAP terminology. A brief mapping is listed here for your convenience:

	SUN				SAP
      --------------------------------------------------
      Logger				Location
      Handler				Log
	  -ConsoleHandler		  -ConsoleLog
	  -FileHandler			  -FileHandler
      Level				Severity
	  -OFF				  -NONE
	  -SEVERE			  -FATAL
 	  -WARNING			  -WARNING
	  -INFO				  -INFO
	  -CONFIG
	  -FINE
	  -FINER			  -PATH
	  -FINEST			  -DEBUG
	  -ALL				  -ALL
	Formatter			Formatter
	  -SimpleFormatter		  -TraceFormatter
	  -XMLFormatter			  -XMLFormatter
   

Note: If users do use the SAP style, the configuration behavior will be identical to that described in PropertiesConfigurator, except the update of 'limit' and 'cnt' attributes of FileLog for a periodic reloading. The current limitation in this version is new values of 'limit' and 'cnt' are ignored upon a periodic reloading.


Constructor Summary
PropertiesConfigurator13(java.io.File file)
          Configures this properties configurator with a properties file and the class loader used for this class.
PropertiesConfigurator13(java.io.File file, java.lang.ClassLoader classLoader)
          Configures this properties configurator with a properties file and a custom class loader.
PropertiesConfigurator13(java.util.Properties properties)
          Configures this properties configurator with a properties object and the class loader used for this class.
PropertiesConfigurator13(java.util.Properties properties, java.lang.ClassLoader classLoader)
          Configures this properties configurator with a properties object and a custom class loader.
 
Method Summary
 void configure()
          Configures tracing and logging according to the settings of the configurator.
 java.io.File getFile()
          Gets the file used for this configurator.
 java.util.Properties getProperties()
          Gets the properties object used for this configurator.
 void setFile(java.io.File file)
          Sets the file used for this configurator.
 void setProperties(java.util.Properties properties)
          Sets the properties object used for this configurator.
 
Methods inherited from class com.sap.tc.logging.Configurator
getClassLoader, getException, getPeriodicity, setClassLoader, setPeriodicity, throwException
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertiesConfigurator13

public PropertiesConfigurator13(java.util.Properties properties)
Configures this properties configurator with a properties object and the class loader used for this class.
Parameters:
properties - Properties object
See Also:
PropertiesConfigurator13(java.util.Properties, java.lang.ClassLoader)

PropertiesConfigurator13

public PropertiesConfigurator13(java.util.Properties properties,
                                java.lang.ClassLoader classLoader)
Configures this properties configurator with a properties object and a custom class loader.
Parameters:
properties - Properties object
classLoader - Custom class loader
See Also:
PropertiesConfigurator13(java.util.Properties)

PropertiesConfigurator13

public PropertiesConfigurator13(java.io.File file)
Configures this properties configurator with a properties file and the class loader used for this class.
Parameters:
file - Properties file
See Also:
PropertiesConfigurator13(java.io.File, java.lang.ClassLoader)

PropertiesConfigurator13

public PropertiesConfigurator13(java.io.File file,
                                java.lang.ClassLoader classLoader)
Configures this properties configurator with a properties file and a custom class loader.
Parameters:
file - Properties file
classLoader - Custom class loader
See Also:
PropertiesConfigurator13(java.io.File)
Method Detail

getProperties

public java.util.Properties getProperties()
Gets the properties object used for this configurator.
Returns:
Properties object, or null if there is none
See Also:
setProperties(java.util.Properties)

setProperties

public void setProperties(java.util.Properties properties)
Sets the properties object used for this configurator.
Parameters:
properties - Properties object
See Also:
getProperties()

getFile

public java.io.File getFile()
Gets the file used for this configurator.
Returns:
File, or null if there is none
See Also:
setFile(java.io.File)

setFile

public void setFile(java.io.File file)
Sets the file used for this configurator.
Parameters:
file - File
Throws:
java.lang.IllegalArgumentException - No file
See Also:
getProperties()

configure

public void configure()
Description copied from class: Configurator
Configures tracing and logging according to the settings of the configurator.
Overrides:
configure in class Configurator