The Art of Logging An exploration with Apache Log4j 2 Gary Gregory [email protected].
APACHE LOGGING and Log4j - Java Forum...
Transcript of APACHE LOGGING and Log4j - Java Forum...
APACHE LOGGINGand Log4j
Christian Grobmeier
@grobmeierhttp://www.grobmeier.de
ASF V. P. Logging Services
Why should you log?
ASFFIRE
BRIGADE
Log4j1, Log4j2log4php
Chainsawlog4netlog4cxx
CHALLENGES
SPEED!
Failsafe. Reliable.
Compability.
Taste.
L o g g i n g with Duke Java
Too much t a s t e . . . m a k e s headache!
Think on: log4j, logback, JUL,
TinyLog, AVSL
Pills: slf4j & Commons Logging
slf4j
Commons Logging
log4j 1
log4j 2logback JUL AVSL
Which pill?
Don‘t forget PAX!
Integrates well with:slf4j
log4j 1.xCommons Logging
log4j 2.0 is the
future of log4j
Why
log4j 2.0?
Instead:if(logger.isDebugEnabled()) logger.info("Hi, " + u.getA() + “ “ + u.getB());
Write:logger.info("Hi, {} {} ", u.getA(), u.getB());
API++
Marker:
Marker SQL_MARKER = MarkerManager.getMarker("SQL");
logger.debug( SQL_MARKER, "SELECT * FROM {}", table);
Better Filter
@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
@PluginFactorypublic static Mine create( @PluginAttr("name") String n, @PluginElement("filters") Filter f) { return new Mine(n, f);}
Plugins
<appenders> <Console name="Console" target="SYSTEM_OUT"> <PatternLayout pattern="%d{HH:mm} %msg%n"/> </Console></appenders>
Configuration
{ "configuration": … "appenders": { "Console": { "name": "STDOUT", "PatternLayout": { "pattern": "%m%n" } }, ...
Configuration
ConfigurationReloading
<configuration monitorInterval="30">...</configuration>
SPEED!
log4j 1.x
logback
log4j 2.x
Disabled 5
2386
2116
2314
Logging Performance in ns
SPEED!Async Logging Power!
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)
WTF?
LMAXDISRUPTOR
removes the kernel need for locks on the CPU level
CHAINSAW
The story of
log4php
Community
Good times,
bad times
2000 2009 2010 2011
You are welcome
Join 6 active committers.
We areback!
7 Releases~1640 Changes~ 4095 Mails
in 2012/2013
Seriously.Isn‘t logging just
BORING?
Well.. . how do you log on your mobile/cloud apps?
With new innovation, new logging challenges
come up.
Logging needs innovation too.Look at Apache Flume.
Remember: Logging is mission critical.
Don‘t go without.
We are hiring!
use it!ask questions!
spread the love!send patches!
Christian Grobmeier
@grobmeierhttp://www.grobmeier.de
Thank you!
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)