loggingservices_readme
SfCoreLoggers Components
Introduction
SfCoreLoggers components are a set of extensions to the logging framework used but the SmartFrog core. Currently the only extension available is a wrapper for the longging framework Log4J (http://logging.apache.org/log4j/).
How to build
-
Build the SmartFrog framework by running ant dist in core/smartfrog
-
Build ant tasks by running ant in core/extras/ant
-
Build sfCoreLoggers by running ant in core/components/sfcoreloggers
-
Step 3 creates one jar file in core/components/sfcoreloggers/build/dist/lib. Copy this jar file and the log4j JAR (1.2.8 or later) to core/smartfrog/dist/lib or update the class path for the SmartFrog daemon so that sfcorelogger classes are available at run time.
- Log4j Wrapper
This wrapper redirects all logging statements from the core logging framework to the Log4J logging framework.
Requires Log4J version 1.2.8 or later
Component Description
Attribute Name | Description | Optional/Mandatory |
configuratorFile | URI to a properties or xml Log4j configuration file. | Optional |
configureAndWatch | Boolean attribute to enable automatic reload of the configuration file only valid when using a local configuration file, not valid for URL. Default false; | Optional |
configureAndWatchDelay | Period to reload the configuration in milliseconds. Default 90000. | Optional |
setIniLog4JLoggerLevel | Boolean to determine if to set initial Log4J level. Default false. | Optional |
ignoreSetLogLevel | Boolean to ignore setLogLevel method. Default false. | Optional |
The first three configuration attributes are directly related to the way log4j manages its configuration files. For more details see Log4j documentation.
Usage
Logging is one of the basic services that the framework needs and it is therefore initialized as soon as it is possible. To determine the initial configuration for the core logging framework it is necessary to define a value for the property org.smartfrog.sfcore.logging.LogImpl.localLoggerClass in this case with the value org.smartfrog.sfcore.logging.logger.LogToLog4JImpl. This can be done for example using an system environment property or the configuration file default.ini. It is also possible to add more than one logger to the log framework and modifine their configuration at runtime
Example
Configuration example for “default.ini” configuration file:
-
To select the Log4j wrapper:
-
org.smartfrog.sfcore.logging.LogImpl.localLoggerClass=org.smartfrog.sfcore.logging.logger.LogToLog4JImpl
-
-
To configure the Log4j wrapper:
-
org.smartfrog.sfcore.logging.logger.LogToLog4JImpl.configuratorFile=d:\\log4jj.xml
-
org.smartfrog.sfcore.logging.logger.LogToLog4JImpl.configureAndWatch=true
-
org.smartfrog.sfcore.logging.logger.LogToLog4JImpl.configureAndWatchDelay=90000
-