Week 1 Log4J/Design Patterns Flashcards
Log4J
is a logging tool that helps us to keep track of whats going on inside of a code.
Log4J is highly configurable, through external configurations at runtime. It views the logging process in terms of levels of priority and offers mechanism to direct logging information to a variety of destinations such as data bases, file, console, Unix Syslog
Why log5j is better than sysout
Log4J is better than using sysout all the time because sysout is a synchronized method that is very costly in terms of processing. Also sysout is not a debugging tool.
A good logging format should let you decide a couple of things
Level - what to log (going from worst to least bad)
- OFF
- FATAL
- ERROR
- WARN
- INFO
- DEBUG
- TRACE
- ALL
Formatting/layout - how to log
- define layout
- date time style
- can output in html format
Appenders - where to log
- log files - in a file for reference later
- console - lost of console out put
Levels explained
ALL - all levels including custom levels.
TRACE - designates finer grained info event than the debug.
DEBUG - designates fine grained info events that are most useful to debut at application.
INFO -designates info messages that highlight the progress of the application a coarse grained level
WARN - designates harmful situations
ERROR - designates error events that might still allow the application to continue running.
FATAL -designates very severe events that will presumably lead the application to abort.
OFF - the highest possible rank and is intended to turn off logging.
log4J.properties
where properties (logging configuration in a file) are kept.
log4J features
- thread safe
- high speed optimization
- multiple appenders support
- customization
- various logging levels
- layout class
log4J Advantages
- Quick debugging
- Easy maintenance
- Structured Storage
log4J Disadvantages
- Slows down app
- Scrolling blindness, due to config file being too verbose.
core objects
Loggers
Appenders
Layouts
Loggers
Responsible for capturing logging information
- Register class to logger
- Gathers the logging info an are captured in the namespace hierarchy.
Appenders
Publish the logging information to the retrospective destination also lower level object.
Layouts
Styles the logging info for readability (ie time stamp.)-
Support Core Objects
Level
Filters
Object Renderer
Log Manager
Level
defines granularity and priority of logging info
Filter
analyze and decide whether to keep the logged info. Appenders can use multiple filters . tells the Appender whether or not to print the loop to the respective destination.