1 / 46

Corporate Training Center

Corporate Training Center. Practical Java Programming Using Log4J. Today agenda. Overview Add Log4J library Create configuration file Add logging initialization statements Add logging code Appender overview Log level overview Layout overview Filter overview. Overview. Log4J Overview.

bstringer
Download Presentation

Corporate Training Center

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Corporate Training Center Practical Java Programming Using Log4J

  2. Today agenda • Overview • Add Log4J library • Create configuration file • Add logging initialization statements • Add logging code • Appender overview • Log level overview • Layout overview • Filter overview

  3. Overview

  4. Log4J Overview • Log message in any place of code • Control many kinds of output by appenders • Customize the logging behavior for a specific code part • Filter the log message by log level, keyword • Format the output message by log layout

  5. Log4J Library

  6. Add library folder

  7. Add library folder dialog

  8. Copy library

  9. Add library

  10. Add library dialog

  11. Add library result

  12. Log4J Configuration file

  13. Content • Add a new configuration file • Register to Assembly • Main structure • Appender Section • Logger Section

  14. Creation

  15. New file created

  16. Main structure

  17. Appenders

  18. Loggers

  19. Summary • Add a new configuration file: Add xml file to the root folder • Main structure: Appenders and loggers • Appender Section: File rolling and console • Logger Section: Root required and specific logger is optional

  20. Log4J Initialize

  21. Initialization code

  22. Logging

  23. Add logging

  24. Multi level logging

  25. Running result

  26. Console Output

  27. File Output

  28. File Output: rolling

  29. File Output: rolling file

  30. appenders

  31. Appender using

  32. Appenders • File rolling • Console • File • Daily File rolling • JDBC – to Database • SMTP – by email • Other…

  33. Log levels

  34. Loggers

  35. Log level using

  36. Log levels • TRACE • DEBUG • INFO • WARN • ERROR • FATAL

  37. Log propagate/Additivity

  38. Log propagate/Additivity

  39. Layout

  40. Layout using

  41. Layouts • PatternLayout • HTMLLayout • SimpleLayout

  42. Filter

  43. Filter using

  44. Filters • DenyAllFilter • LevelMatchFilter • LevelRangeFilter • StringMatchFilter

  45. Lesson summary • Add Log4J library: add reference in build path • Create configuration file: xml file • Add logging initialization statements: in main java file • Add logging code: in each module • Appender overview: File rolling, console, SQL • Log level overview: 6 options • Layout overview: output format • Filter overview: output restriction

  46. Thank for your attention Happy Coding ! 

More Related