christian trutz c.trutz@cenit - eclipsecon france2018 · in theory yes, but some (legacy)...
TRANSCRIPT
www.cenit.de
www.cenit-group.com
Logback Beagle
Eclipse Logging reinvented
Christian Trutz
Who am I?
Christian Trutz, a software engineer working at CENIT AG
(ECE 2012 sponsor)
Great software company in Germany
Initiator and contributor of egit-github
Initial code donation to Eclipse becomes
egit-github project
SLF4J / Logback commiter
Great cooperation with Ceki Gülkü and others
Purpose
Motivation
Java developers are also bug hunters
Show you ideas behind Beagle
Logback sends log messages over TCP/IP
Logback Beagle receives the log messages
and display them in your local Eclipse instance
Animate you to use Beagle
and contribute to it
With bug correction, code, ideas, etc.
https://github.com/qos-ch/logback-beagle
Show you Beagle in action (with real world examples), but also
problems, discussions and challenges
Beagles “Hello world!”
Jars needed
slf4j-api.jar, logback-core.jar, logback-classic.jar
Trivial logback.xml in your classpath
<configuration> <consolePlugin /> </configuration>
This is only a shortcut for the Logback SocketAppender, see also
http://logback.qos.ch/manual/appenders.html
Code logging via standard SLF4J
logger.debug("Hello World!");
For „Hello world!“ example look also at GitHub
https://github.com/belaso/ece2012
Big picture
TCP/IP
Application
slf4j.jar
logback.jar
logback.xml
Features
Jump to caller
on every log message
Expand caller data
stack trace on every log message, not only on errors
Tree filter
Change log level on each level and filter messages
Well integrated with Eclipse
Preference page, font configuration
Real world example / challenges
Some (legacy) applications use Log4J / JUL / Commons Logging
no problem, with log4j-over-slf4j.jar, jul-to-slf4j.jar, jcl-over-slf4j.jar
TCP/IP
Application
log4j-over-slf4j.jar
slf4j.jar
logback.jar
logback.xml
Backend
Server
(VM) api.jars
Real world example / challenges
Can you use every API with Beagle?
In theory YES, but some (legacy) applications not only use Log4J, they also modify
Log4J, e.g. inherit Log4J logger
My recommendation: use SLF4J in your code
If you have some nasty API using Log4J, JCL, JUL in a „special“ way, then throw
away this API ;-) or if not possible, try to resolve problems and commit them to SLF4J
How about OSGi?
osgi-over-slf4j.jar is the right way
osgi-over-slf4j.jar registers a OSGi LogService which transfer all log
messages to SLF4J
slf4j.jar and logback.jars are bundles (nice!)
„natural“ place for logback.xml is a logback.jar fragment
how about OSGi service ranking (Equinox has ist own LogService)
bundle start level is also important
Start SLF4J LogService before starting you application
Enjoy Beagle!
here some useful links:
http://logback.qos.ch/
http://www.slf4j.org/
https://github.com/qos-ch/slf4j
http://logback.qos.ch/beagle/
https://github.com/qos-ch/logback-beagle
https://github.com/belaso/ece2012 (examples of this presentation)