Logback project Ceki Glc Sbastien Pennec 1 No
![Logback project Ceki Gülcü & Sébastien Pennec 1 Logback project Ceki Gülcü & Sébastien Pennec 1](https://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-1.jpg)
Logback project Ceki Gülcü & Sébastien Pennec 1
![~ No revolution, only evolution. n log 4 j is no longer being actively ~ No revolution, only evolution. n log 4 j is no longer being actively](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-2.jpg)
~ No revolution, only evolution. n log 4 j is no longer being actively developed n The same basic plumbing only done better. n Faster, smaller, higher gas mileage, and generally more bang for the buck. n 2
![Modular architecture logback-core Joran, Status, Context, pattern parsing n logback-classic developer logging n logback-access Modular architecture logback-core Joran, Status, Context, pattern parsing n logback-classic developer logging n logback-access](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-3.jpg)
Modular architecture logback-core Joran, Status, Context, pattern parsing n logback-classic developer logging n logback-access container (access) logging n 3
![Access Logging n Definition: Access log The log generated when a user accesses a Access Logging n Definition: Access log The log generated when a user accesses a](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-4.jpg)
Access Logging n Definition: Access log The log generated when a user accesses a web-page on a web server. n Logback-access integrates seamlessly with Jetty and Tomcat 4
![logback-classic implements SLF 4 J Logback offers a native implementation of the SLF 4 logback-classic implements SLF 4 J Logback offers a native implementation of the SLF 4](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-5.jpg)
logback-classic implements SLF 4 J Logback offers a native implementation of the SLF 4 J API => Logback exposes its logging API through SLF 4 J. n If you are using logback, you are actually using SLF 4 J n SLF 4 J can delegate to log 4 j, logback, java. util. logging or JCL n SLF 4 J can bridge log 4 j, JCL and j. u. l. n 5
![Joran: a bowl of fresh air Given rules (patterns & actions) it can configure Joran: a bowl of fresh air Given rules (patterns & actions) it can configure](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-6.jpg)
Joran: a bowl of fresh air Given rules (patterns & actions) it can configure any object. n Joran can learn new rules on the fly. n With its implicit rules, you don’t even have to write rules. n It can do partial replay. n It is generic (can be used in your own projects) n 6
![Configuration example: <appender name="FILE" class="ch. qos. logback. core. rolling. Rolling. File. Appender"> <File>log. File. Configuration example: <appender name="FILE" class="ch. qos. logback. core. rolling. Rolling. File. Appender"> <File>log. File.](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-7.jpg)
Configuration example: <appender name="FILE" class="ch. qos. logback. core. rolling. Rolling. File. Appender"> <File>log. File. log</File> <rolling. Policy class="ch. qos. logback. core. rolling. Time. Based. Rolling. Policy"> <File. Name. Pattern> log. File. %d{yyyy-MM-dd}. log. zip </File. Name. Patter> </rolling. Policy> <layout class="ch. qos. logback. classic. Pattern. Layout"> <Pattern> %d{HH: mm: ss, SSS} [%thread] %-5 level %logger{22} - %msg%n </Pattern> </layout> </appender> 7
![Logback-access configuration <appender name="FILE" class="c. q. l. c. r. Rolling. File. Appender"> <File>access. log"</File> Logback-access configuration <appender name="FILE" class="c. q. l. c. r. Rolling. File. Appender"> <File>access. log"</File>](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-8.jpg)
Logback-access configuration <appender name="FILE" class="c. q. l. c. r. Rolling. File. Appender"> <File>access. log"</File> <rolling. Policy class="c. q. l. c. r. Time. Based. Rolling. Policy"> <File. Name. Pattern> access. %d{yyyy-MM-dd}. log. zip </File. Name. Pattern> </rolling. Policy> <layout class="c. q. l. access. Pattern. Layout"> <Pattern">combined</Pattern"> </layout> </appender> 8
![Another example: <test. Shell name="test 1"> <period>5 minutes</period> <!-- we need to configure a Another example: <test. Shell name="test 1"> <period>5 minutes</period> <!-- we need to configure a](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-9.jpg)
Another example: <test. Shell name="test 1"> <period>5 minutes</period> <!-- we need to configure a totally new test object for each run of the test --> <test class="com. wombat. my. Test"> <Data. Source class="c. w. JNDIDS"> <url>jndi: //com. wombat/ds"</url> </Data. Source> </test> <test. Shell name="test 2"> <period>60 seconds</period> <test class="com. wombat. my. Test 2"> <file>c: /wombat/foo. properties</file> </test> </test. Shell> 9
![Is Joran for me? n Joran is ideal for building frameworks which need to Is Joran for me? n Joran is ideal for building frameworks which need to](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-10.jpg)
Is Joran for me? n Joran is ideal for building frameworks which need to support arbitrary userdeveloped plug-ins. 10
![Internal error reporting n Who shall guard the guards? n Logback modules cannot use Internal error reporting n Who shall guard the guards? n Logback modules cannot use](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-11.jpg)
Internal error reporting n Who shall guard the guards? n Logback modules cannot use logging to report their own state. n Something more generic is needed. 11
![Errors in action n Internal state available via Status. Manager n Exceptions and status Errors in action n Internal state available via Status. Manager n Exceptions and status](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-12.jpg)
Errors in action n Internal state available via Status. Manager n Exceptions and status messages accompanied by references, i. e. URLs, to external documents 12
![JMX n Logback configuration can be reloaded via JMX n Statistical results exposed via JMX n Logback configuration can be reloaded via JMX n Statistical results exposed via](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-13.jpg)
JMX n Logback configuration can be reloaded via JMX n Statistical results exposed via JMX 13
![Documentation n Major area of effort. n Complete manual, with over 150 pages of Documentation n Major area of effort. n Complete manual, with over 150 pages of](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-14.jpg)
Documentation n Major area of effort. n Complete manual, with over 150 pages of documentation, is available for free n A short introduction to access logging with logback-access and Jetty n javadoc, FAQ, error codes, … 14
![Filters, Filters everywhere Filters attachable to any Appender n Evaluator filters n Janino filters Filters, Filters everywhere Filters attachable to any Appender n Evaluator filters n Janino filters](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-15.jpg)
Filters, Filters everywhere Filters attachable to any Appender n Evaluator filters n Janino filters for evaluation based on java expressions n Turbo. Filters for optimized global processing n 15
![Evaluator. Filter & Janino <appender name="CYCLIC" class="c. q. l. core. read. Cyclic. Buffer. Appender"> Evaluator. Filter & Janino <appender name="CYCLIC" class="c. q. l. core. read. Cyclic. Buffer. Appender">](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-16.jpg)
Evaluator. Filter & Janino <appender name="CYCLIC" class="c. q. l. core. read. Cyclic. Buffer. Appender"> <filter class="c. q. l. core. filter. Evaluator. Filter"> <evaluator name="logging. Task. Eval"> <expression> logger. contains("Logging. Task") && message. contains("Howdydy-diddly-ho") && (time. Stamp-logger. Context. get. Birth. Time()) >= 20000 </expression> </evaluator> <On. Match>DENY</On. Match> </filter> <Max. Size>512</Max. Size> </appender> 16
![Turbo. Filters <turbo. Filter class="c. q. l. classic. turbo. MDCFilter"> <MDCKey>userid</MDCKey> <Value>sebastien</Value> <On. Match>ACCEPT</On. Turbo. Filters <turbo. Filter class="c. q. l. classic. turbo. MDCFilter"> <MDCKey>userid</MDCKey> <Value>sebastien</Value> <On. Match>ACCEPT</On.](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-17.jpg)
Turbo. Filters <turbo. Filter class="c. q. l. classic. turbo. MDCFilter"> <MDCKey>userid</MDCKey> <Value>sebastien</Value> <On. Match>ACCEPT</On. Match> </turbo. Filter> 17
![Parameterized logging Integer entry = new Interger(50); logger. debug("The entry is "+entry+". "); can Parameterized logging Integer entry = new Interger(50); logger. debug("The entry is "+entry+". "); can](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-18.jpg)
Parameterized logging Integer entry = new Interger(50); logger. debug("The entry is "+entry+". "); can be optimized as: if(logger. is. Debug. Enabled()) { logger. debug("The entry is "+entry+". "); } or better yet: logger. debug("The entry is {}. ", entry); 18
![Markers for specialized handling n Markers are metadata for logging statements, coloring them for Markers for specialized handling n Markers are metadata for logging statements, coloring them for](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-19.jpg)
Markers for specialized handling n Markers are metadata for logging statements, coloring them for specialized processing 19
![Sifting. Appender or the appendermaking appender Sift logging according to runtime attributes n E. Sifting. Appender or the appendermaking appender Sift logging according to runtime attributes n E.](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-20.jpg)
Sifting. Appender or the appendermaking appender Sift logging according to runtime attributes n 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. n Works with any appender, not just File. Appender n 20
![Sifting. Appender (continued) <appender name="SIFT" class="ch. qos. logback. classic. sift. Sifting. Appender"> <discriminator> <Key>userid</Key> Sifting. Appender (continued) <appender name="SIFT" class="ch. qos. logback. classic. sift. Sifting. Appender"> <discriminator> <Key>userid</Key>](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-21.jpg)
Sifting. Appender (continued) <appender name="SIFT" class="ch. qos. logback. classic. sift. Sifting. Appender"> <discriminator> <Key>userid</Key> <Default. Value>unknown</Default. Value> </discriminator> <sift> <appender name="FILE-${userid}" class="ch. qos. logback. core. File. Appender"> <File>${userid}. log</File>s <Append>false</Append> <layout> <Pattern>%d %level %mdc %logger - %msg%n</Pattern> </layout> </appender> </sift> </appender> 21
![Tested & Ready n Battery of over 450 unit tests n Tests written concomitantly Tested & Ready n Battery of over 450 unit tests n Tests written concomitantly](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-22.jpg)
Tested & Ready n Battery of over 450 unit tests n Tests written concomitantly with the code 22
![Package versions in stack traces java. lang. Null. Pointer. Exception at com. xyz. Wombat(Wombat. Package versions in stack traces java. lang. Null. Pointer. Exception at com. xyz. Wombat(Wombat.](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-23.jpg)
Package versions in stack traces java. lang. Null. Pointer. Exception 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. Native. Method. Accessor. Impl. invoke 0(Native) ~[na: 1. 5. 0_06] at java. lang. reflect. Method. invoke(Method. java: 585) ~[na: 1. 5. 0_06] at junit. runners. Test. Method. invoke(Test. Method. java: 59) [junit-4. 4. jar: na] etc. . 23
![logger name abbreviation Conversion specifier Displayed logger name %logger main. Package. sub. sample. Bar logger name abbreviation Conversion specifier Displayed logger name %logger main. Package. sub. sample. Bar](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-24.jpg)
logger name abbreviation Conversion specifier Displayed logger name %logger main. Package. sub. sample. Bar %logger{15} m. s. sample. Bar 24
![Odds and ends n n Rolling. File. Appender automatic file compression the background File. Odds and ends n n Rolling. File. Appender automatic file compression the background File.](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-25.jpg)
Odds and ends n n Rolling. File. Appender automatic file compression the background File. Appender and Rolling. File. Appender 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 Pattern. Layout 25
![Odds and ends II %() in pattern strings can do magic %-50(%d %level [%thread]) Odds and ends II %() in pattern strings can do magic %-50(%d %level [%thread])](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-26.jpg)
Odds and ends II %() in pattern strings can do magic %-50(%d %level [%thread]) - %m%n n Duplicate. Message filter n 26
![Odds and ends II %() in pattern strings can do magic %-50(%d %level [%thread]) Odds and ends II %() in pattern strings can do magic %-50(%d %level [%thread])](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-27.jpg)
Odds and ends II %() in pattern strings can do magic %-50(%d %level [%thread]) - %m%n n Duplicate. Message filter n 27
![Plans for the near future n n n Finer threading model leading to less Plans for the near future n n n Finer threading model leading to less](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-28.jpg)
Plans for the near future n n n Finer threading model leading to less contention Better documentation Eclipse plug-in to visualize your logs 28
![Conclusion n Logback is the unofficial successor of log 4 j, as the latter Conclusion n Logback is the unofficial successor of log 4 j, as the latter](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-29.jpg)
Conclusion n Logback is the unofficial successor of log 4 j, as the latter is no longer being actively developed. 29
![Questions? read the docs at http: //logback. qos. ch/ n study the code at Questions? read the docs at http: //logback. qos. ch/ n study the code at](http://slidetodoc.com/presentation_image_h/9c9b864814d78eb3ffa2852e27cce454/image-30.jpg)
Questions? read the docs at http: //logback. qos. ch/ n study the code at http: //svn. qos. ch n write to us at logback-user@qos. ch n file a bug report at http: //jira. qos. ch/ n chat with us at irc. freenode. net#qos n talk to us at +41 21 312 32 26 n 30
- Slides: 30