Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A-Stack runtime supports number of different logging systems -

  1. sff SffLog -  A-Stack provided logging system
  2. log4j -  Via OPS4j PAX Logging
  3. slf4j
  4. jakarta commons
  5. avalon
  6. JUL 


Following section Another reason is that different components/libraries may use different logging systems and developer (as a library consumer) might not have a choice on the matter.

I’ve heard heated discussions about which logging system is better and for what. I’ve never heard of anyone getting confused about that.

Application Logging

A-Stack allows users to log messages into log filesdescribes configuration of the different logging systems. 

Code Block
languagexml
titleConfiguring sff.log
linenumberstrue
<ConfigurationAdmin service.pid="sff.log">
      sff.log=enabled,silent
</ConfigurationAdmin


Code Block
languagexml
titleConfiguring PAX Logging
linenumberstrue
<ConfigurationAdmin service.pid="org.ops4j.pax.logging">
                log4j.rootLogger=[:logs4j.level:], R
                log4j.appender.R=org.apache.log4j.RollingFileAppender
                log4j.appender.R.File=[:log4j.logsdir:]/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>

Logging Notes

  1. 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.
  2. 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.
  3. More than one service can be configured.
  4. A-Stack own SffLog can be configured this way as show in code above.
  5. 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).
  6. All the logs posted to sff.log will also appear in log4j, but not vice versa, so sff.log remains our main logging system.
  7. 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
  8. 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.

Broadcast Log Message

A-Stack allows users to provide facet id on which all the log messages can be broadcast.

...