Logback project Ceki Gülcü & Sébastien Pennec



Yüklə 453 b.
tarix11.09.2018
ölçüsü453 b.
#80607


Logback project

  • Ceki Gülcü & Sébastien Pennec


~

  • No revolution, only evolution.

  • log4j is no longer being actively developed

  • The same basic plumbing only done better.

  • Faster, smaller, higher gas mileage, and generally more bang for the buck.



Modular architecture

  • logback-core

  • Joran, Status,

  • Context, pattern parsing

  • logback-classic

  • developer logging

  • logback-access

  • container (access) logging



Access Logging

  • Definition: Access log

  • The log generated when a user accesses a web-page on a web server.

  • Logback-access integrates seamlessly with Jetty and Tomcat



logback-classic implements SLF4J

  • Logback offers a native implementation of the SLF4J API => Logback exposes its logging API through SLF4J.

  • If you are using logback, you are actually using SLF4J

  • SLF4J can delegate to log4j, logback, java.util.logging or JCL

  • SLF4J can bridge log4j, JCL and j.u.l.



Joran: a bowl of fresh air

  • Given rules (patterns & actions) it can configure any object.

  • Joran can learn new rules on the fly.

  • With its implicit rules, you don’t even have to write rules.

  • It can do partial replay.

  • It is generic (can be used in your own projects)



Configuration example:

  • >

  • logFile.log

  • >

  • logFile.%d{yyyy-MM-dd}.log.zip


  • %d{HH:mm:ss,SSS} [%thread] %-5level %logger{22} - %msg%n




Logback-access configuration

  • >

  • access.log"

  • >

  • access.%d{yyyy-MM-dd}.log.zip


  • combined



Another example:


  • 5 minutes

  • object for each run of the test -->

  • jndi://com.wombat/ds"


  • 60 seconds

  • c:/wombat/foo.properties



Is Joran for me?

  • Joran is ideal for building frameworks which need to support arbitrary user-developed plug-ins.



Internal error reporting

  • Who shall guard the guards?

  • Logback modules cannot use logging to report their own state.

  • Something more generic is needed.



Errors in action

  • Internal state available via StatusManager

  • Exceptions and status messages accompanied by references, i.e. URLs, to external documents



JMX

  • Logback configuration can be reloaded via JMX

  • Statistical results exposed via JMX



Documentation

  • Major area of effort.

  • Complete manual, with over 150 pages of documentation, is available for free

  • A short introduction to access logging with logback-access and Jetty

  • javadoc, FAQ, error codes,…



Filters, Filters. Filters everywhere

  • Filters attachable to any Appender

  • Evaluator filters

  • Janino filters for evaluation based on java expressions

  • TurboFilters for optimized global processing



EvaluatorFilter & Janino

  • >

  • logger.contains("LoggingTask") &&

  • message.contains("Howdydy-diddly-ho") &&

  • (timeStamp-loggerContext.getBirthTime()) >= 20000

  • DENY

  • 512



TurboFilters

  • >

  • userid

  • sebastien

  • ACCEPT



Parameterized logging

  • Integer entry = new Interger(50);

  • logger.debug("The entry is "+entry+".");

  • can be optimized as:

  • if(logger.isDebugEnabled()) {

  • logger.debug("The entry is "+entry+".");

  • }

  • or better yet:

  • logger.debug("The entry is {}.", entry);



Markers for specialized handling

  • Markers are metadata for logging statements, coloring them for specialized processing



SiftingAppender or the appender-making appender

  • Sift logging according to runtime attributes

  • E.g. separate logs according to user sessions, so that the log file generated by every user go into distinct log files, one log file per user.

  • Works with any appender, not just FileAppender



SiftingAppender (continued)

  • userid

  • unknown

  • >

  • >${userid}.logs

  • false


  • %d %level %mdc %logger - %msg%n



Tested & Ready

  • Battery of over 450 unit tests

  • Tests written concomitantly with the code



Package versions in stack traces

  • java.lang.NullPointerException

  • at com.xyz.Wombat(Wombat.java:57) ~[wombat-1.3.jar:1.3]

  • at com.xyz.Wombat(Wombat.java:76) ~[wombat-1.3.jar:1.3]

  • at sun.reflect.NativeMethodAccessorImpl.invoke0(Native) ~[na:1.5.0_06]

  • at java.lang.reflect.Method.invoke(Method.java:585) ~[na:1.5.0_06]

  • at junit.runners.TestMethod.invoke(TestMethod.java:59) [junit-4.4.jar:na]

  • etc..



logger name abbreviation



Odds and ends

  • RollingFileAppender automatic file compression the background

  • FileAppender and RollingFileAppender allow for the same log file to be written to by instances located in different JVMs

  • 10 fold improvement in the speed of transporting logging events over the wire

  • SMTPAppender now does TLS and SSL, subject line in outgoing email now based on PatternLayout



Odds and ends II

  • %() in pattern strings can do magic

  • %-50(%d %level [%thread]) - %m%n

  • DuplicateMessage filter



Odds and ends II

  • %() in pattern strings can do magic

  • %-50(%d %level [%thread]) - %m%n

  • DuplicateMessage filter



Plans for the near future

  • Finer threading model leading to less contention

  • Better documentation

  • Eclipse plug-in to visualize your logs



Conclusion

  • Logback is the unofficial successor of log4j, as the latter is no longer being actively developed.



Questions?

  • read the docs at http://logback.qos.ch/

  • study the code at http://svn.qos.ch

  • write to us at logback-user@qos.ch

  • file a bug report at http://jira.qos.ch/

  • chat with us at irc.freenode.net#qos

  • talk to us at +41 21 312 32 26



Yüklə 453 b.

Dostları ilə paylaş:




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©muhaz.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin