Loggly - Tools and Techniques For Logging Microservices
Service Logging
1. OSGi Logging: The basics
Two parts in a logger: the client bundle who
wants to log and the back-end to manage
logs
– A very simple API for the client side
– The logging back-end, or how the log entries are
displayed, stored, or processed is currently not
defined by the OSGI specifications [1]
1 Velossity@Training 2012-Services/Log/1
2. Separation of concerns
Application developers just choose when and
what to log, with which log level
Platform administrators choose how the log
entries are displayed, stored, or processed
– logging strategy can be defined not only in terms
of packages and classes, but also in terms of
services and bundles [1]
2 Velossity@Training 2012-Services/Log/1
6. Alternative: The logging bridge
The easy way to log with OSGi is to use an
“old java logging API” acting like a façade
Such solution uses a LogService
implementation as the back-end for the Log
implementation
– Pros: compliant with Java world
– Cons: not easily swappable as your code don’t
rely on the standard OSGi service
6 Velossity@Training 2012-Services/Log/1
8. JCL open implementations
Pax Logging Compliant with most popular logger APIs
(JCL, sl4j,JDK logging, …)
Uses Log4j as back-end
Easily and dynamically configurable
Knopflerfish Basic back-end
logger Defines a Log command
8 Velossity@Training 2012-Services/Log/1
10. Recommendations
Choose one API for all your clients
Define clearly the log levels
Bind to the Logging Service only if using
Dynamic frameworks
Ensure that log4j.jar, commons-logging.jar, and
any other legacy API that you want to use, are
NOT included in your bundle jars
10 Velossity@Training 2012-Services/Log/1