christian trutz c.trutz@cenit - eclipsecon france2018 · in theory yes, but some (legacy)...

10
www.cenit.de www.cenit-group.com Logback Beagle Eclipse Logging reinvented Christian Trutz [email protected]

Upload: others

Post on 11-Feb-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Christian Trutz c.trutz@cenit - EclipseCon France2018 · In theory YES, but some (legacy) applications not only use Log4J, they also modify Log4J, e.g. inherit Log4J logger My recommendation:

www.cenit.de

www.cenit-group.com

Logback Beagle

Eclipse Logging reinvented

Christian Trutz

[email protected]

Page 2: Christian Trutz c.trutz@cenit - EclipseCon France2018 · In theory YES, but some (legacy) applications not only use Log4J, they also modify Log4J, e.g. inherit Log4J logger My recommendation:

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

Page 3: Christian Trutz c.trutz@cenit - EclipseCon France2018 · In theory YES, but some (legacy) applications not only use Log4J, they also modify Log4J, e.g. inherit Log4J logger My recommendation:

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

Page 4: Christian Trutz c.trutz@cenit - EclipseCon France2018 · In theory YES, but some (legacy) applications not only use Log4J, they also modify Log4J, e.g. inherit Log4J logger My recommendation:

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

Page 5: Christian Trutz c.trutz@cenit - EclipseCon France2018 · In theory YES, but some (legacy) applications not only use Log4J, they also modify Log4J, e.g. inherit Log4J logger My recommendation:

Big picture

TCP/IP

Application

slf4j.jar

logback.jar

logback.xml

Page 6: Christian Trutz c.trutz@cenit - EclipseCon France2018 · In theory YES, but some (legacy) applications not only use Log4J, they also modify Log4J, e.g. inherit Log4J logger My recommendation:

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

Page 7: Christian Trutz c.trutz@cenit - EclipseCon France2018 · In theory YES, but some (legacy) applications not only use Log4J, they also modify Log4J, e.g. inherit Log4J logger My recommendation:

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

Page 8: Christian Trutz c.trutz@cenit - EclipseCon France2018 · In theory YES, but some (legacy) applications not only use Log4J, they also modify Log4J, e.g. inherit Log4J logger My recommendation:

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

Page 9: Christian Trutz c.trutz@cenit - EclipseCon France2018 · In theory YES, but some (legacy) applications not only use Log4J, they also modify Log4J, e.g. inherit Log4J logger My recommendation:

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

Page 10: Christian Trutz c.trutz@cenit - EclipseCon France2018 · In theory YES, but some (legacy) applications not only use Log4J, they also modify Log4J, e.g. inherit Log4J logger My recommendation:

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)