...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<ConfigurationAdmin service.pid="org.ops4j.pax.logging"> log4j.rootLogger=[:logs4jsff.log.level:], R log4j.appender.R=org.apache.log4j.RollingFileAppender log4j.appender.R.File=[:log4jsff.logs.logsdirdir:]/engine.log log4j.appender.R.DatePattern='.'yyyy-MM-dd log4j.appender.R.MaxFileSize=20Mb # Keep one backup file log4j.appender.R.MaxBackupIndex=20 log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=[%d] %p %c [%t] %m%n </ConfigurationAdmin> |
...
- Ability to configure any OSGi service by its service.pid (i.e. persistent ID, see OSGi specs for more details). Only service.pid is supported at this time. The way you do it as described in sections above.
- ConfigugurationAdmin is the standard OSGi service responsible for configuration of other services. The configuration target is defined by service.pid="org.ops4j.pax.logging" attribute. In this case we configure pax/log4j logging. Argument format is the same properties format or XML as described above.
- More than one service can be configured.
- A-Stack own SffLog can be configured this way as show in code above.
- You can control it on per level attribute basis (e.g. sff.log.trace.enabled=true, sff.log.trace.silent=true), per level basis (e.g. sff.log.trace=enabled,silent) or the whole thing altogether (e.g. sff.log=silent).
- All the logs posted to sff.log will also appear in log4j, but not vice versa, so sff.log remains our main logging system.
- Note that both logging systems are configured independently therefore if you configure log4j with console appender and leave sff.log loud then you’ll get each message posted on your console twice in different formats, one from sff.log and another from log4j
The example log4j configuration above only outputs into a log file and leaves console output to sff.log. Adding log4j console appender (e.g. log4j.rootLogger=INFO, A1,FILE) and setting sff.log=silent will use log4j for both console and file logging.
Logging Enable Configuration Matrix
SffLog | Log4j Configured | Result | Comments |
---|---|---|---|
sff.log=disabled,silent | YES | No Logs |
|
sff.log=enabled,silent | YES; sff.log.level="INFO" | Only INFO Level log statements as specified in log4j appender | Absolutely no log file at all |
sff.log=enabled,loud | YES; sff.log.level="INFO" | INFO, ERROR and WARN statements are printed in log | Note that sff.log.level is passed into rootLogger value of Log4j configurationAdmin |
sff.log=enabled,loud | YES; sff.log.level="DEBUG" | INFO, ERROR, WARN, DEBUG statements are printed in log | |
sff.log=enabled,loud sff.log.trace=enabled | YES; sff.log.level="TRACE" | Trace will be enabled; Trace allows you to view Protocol level details for example | This is how trace can be enabled. |
Broadcast Log Message
A-Stack allows users to provide facet id on which all the log messages can be broadcast.
...