APACHE LOGGING and Log4j - Java Forum...

42
APACHE LOGGING and Log4j

Transcript of APACHE LOGGING and Log4j - Java Forum...

Page 1: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

APACHE LOGGINGand Log4j

Page 2: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Christian Grobmeier

@grobmeierhttp://www.grobmeier.de

ASF V. P. Logging Services

Page 3: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Why should you log?

Page 4: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

ASFFIRE

BRIGADE

Page 5: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Log4j1, Log4j2log4php

Chainsawlog4netlog4cxx

Page 6: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

CHALLENGES

Page 7: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

SPEED!

Page 8: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Failsafe. Reliable.

Page 9: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Compability.

Page 10: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Taste.

Page 11: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

L o g g i n g with Duke Java

Page 12: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Too much t a s t e . . . m a k e s headache!

Think on: log4j, logback, JUL,

TinyLog, AVSL

Page 13: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Pills: slf4j & Commons Logging

Page 14: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

slf4j

Commons Logging

log4j 1

log4j 2logback JUL AVSL

Which pill?

Don‘t forget PAX!

Page 15: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Integrates well with:slf4j

log4j 1.xCommons Logging

log4j 2.0 is the

future of log4j

Page 16: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Why

log4j 2.0?

Page 17: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Instead:if(logger.isDebugEnabled()) logger.info("Hi, " + u.getA() + “ “ + u.getB());

Write:logger.info("Hi, {} {} ", u.getA(), u.getB());

API++

Page 18: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Marker:

Marker SQL_MARKER = MarkerManager.getMarker("SQL");

logger.debug( SQL_MARKER, "SELECT * FROM {}", table);

Better Filter

Page 19: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

@Plugin(name = "Sandbox", type = "Core", elementType = "appender")

public class Mine extends AppenderBase {

private Mine(String name, Filter f) { super(name, f, null); } public void append(LogEvent e) { … }

Plugins

Page 20: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

@PluginFactorypublic static Mine create( @PluginAttr("name") String n, @PluginElement("filters") Filter f) { return new Mine(n, f);}

Plugins

Page 21: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

<appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{HH:mm} %msg%n"/> </Console></appenders>

Configuration

Page 22: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

{ "configuration": … "appenders": { "Console": { "name": "STDOUT", "PatternLayout": { "pattern": "%m%n" } }, ...

Configuration

Page 23: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

ConfigurationReloading

<configuration monitorInterval="30">...</configuration>

Page 24: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

SPEED!

log4j 1.x

logback

log4j 2.x

Disabled 5

2386

2116

2314

Logging Performance in ns

Page 25: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

SPEED!Async Logging Power!

Page 26: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Again:

>18,000,000messages / second

On Solaris 10 (64bit) with JDK1.7.0_06, 4-core Xeon X5570 dual CPU @2.93Ghz with hyperthreading switched on (16 virtual cores)

Page 27: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

WTF?

Page 28: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

LMAXDISRUPTOR

removes the kernel need for locks on the CPU level

Page 29: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0
Page 30: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

CHAINSAW

Page 31: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0
Page 32: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

The story of

log4php

Community

Page 33: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Good times,

bad times

2000 2009 2010 2011

Page 34: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

You are welcome

Join 6 active committers.

Page 35: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

We areback!

7 Releases~1640 Changes~ 4095 Mails

in 2012/2013

Page 36: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Seriously.Isn‘t logging just

BORING?

Page 37: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Well.. . how do you log on your mobile/cloud apps?

Page 38: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

With new innovation, new logging challenges

come up.

Logging needs innovation too.Look at Apache Flume.

Page 39: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Remember: Logging is mission critical.

Don‘t go without.

Page 40: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

We are hiring!

use it!ask questions!

spread the love!send patches!

[email protected]

Page 41: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Christian Grobmeier

@grobmeierhttp://www.grobmeier.de

Thank you!

Page 42: APACHE LOGGING and Log4j - Java Forum Stuttgart2013.java-forum-stuttgart.de/_data/2013_A7-Christian_Grobmeier.pdf · Integrates well with: slf4j log4j 1.x Commons Logging log4j 2.0

Image CreditsWriting Girl (Erin Kohlenberg)

Vulcano (Martin Barland)Fire Brigade (State Library of South Australia)

Gear Necklace Designs (Eric Skiff)Gazelle (Flickr: fwooper)

Golden Gate Bridge (Flickr: TimeLapseBlog.com)Pens (Flickr: JD | Photography)

Wineglass (Flickr: Willia4)Headache (Flickr: Threephin)Pills (Dr. Michael Günther)

Wheelgear (Flickr: ralphbijker)Grapes (Flickr: RVWithTito)

Chainsaw (Flickr: Dave Hosford)Elephant (Flickr: Werner Vermaak)Haunted House (Flickr: barb_ar)SOS (Flickr: Daquella Manera)

Bathtime muscles (Flickr: mollypop)Yawning Animal (Flickr: robef)

Mobile (Flickr: twicepix)Clouds (Flickr: karindalziel)

Fight (Flickr: KellBailey)