Mono Log Monitoring Logging Sebastien chassandeinrialpes fr Object
Mono. Log Monitoring & Logging Sebastien. chassande@inrialpes. fr Object. Web Consortium
Summary I. Goals II. Architecture III. Intrumentation IV. Log 4 j & Java. Log wrapper V. Packaging Object. Web Consortium (Mono. Log) - D 2 - 2001/09/19
I. Goals èDissociate source code instrumentation to a logging implementation. èSupport a component architecture. èSame API for logging and monitoring. èEfficient implementation of logging. èSupport internationalisation Object. Web Consortium (Mono. Log) - D 3 - 2001/09/19
II. Architecture: Overview • Objects make logging calls log(level, event) Object Instance • Topical. Logger = Logger extension = event router Logger Handler Object Instance Topical. Logger Handler • Handler ~ output Object. Web Consortium (Mono. Log) - D 4 - 2001/09/19
II. Architecture: Level èLevel Interface èRepresents the event importance èFive predefined levels (in Basic. Level class): ØFATAL ØERROR ØWARN ØINFO ØDEBUG è= Log 4 j priority èFlyweight pattern to reduce cost (Integer) Object. Web Consortium (Mono. Log) - D 5 - 2001/09/19
II. Architecure: Handler èRepresents an output (Can be a file output, a console output, . . ) èEmpty interface ~ tag Object. Web Consortium (Mono. Log) - D 6 - 2001/09/19
II. Architecure: Logger èExtends Handler èInterface for the instrumentation èLog methods: Ølog(Level l, Object event) Ølog(Level l, Object event, Throwable t) Ølog(Level l, Object event, Object instance, Object method) Ølog(Level l, Object event, Throwable t, Object instance, Object method) Ø+ Same method with int instead Level èLevel assessors : get/set/is. Loggable (Level & int) Object. Web Consortium (Mono. Log) - D 7 - 2001/09/19
II. Architecture: Topical. Logger èInterface, extends Logger (Handler too) èLinked to the configuration aspect èManages Handler list (add/remove) èIs a named entity (dotted java. lang. String) => Hierachical namespace => inherits parent Level & parent Handlers èMultiple names (add/remove) => support the sharing component Object. Web Consortium (Mono. Log) - D 8 - 2001/09/19
II. Architecture: Logger. Factory èInterface to fetch a Logger (Topical. Logger too) èMethods: ØLogger get. Logger(String key) key = initial topic (package or class name) ØLogger get. Logger(String key, String resource. Bundle. Name) to support internationalisation èHow to found a Logger. Factory ? ØComponent initialisation Østatic variable in near class ~ Logger. Factory Manager Provide a Default Logger. Factory. Manager Object. Web Consortium (Mono. Log) - D 9 - 2001/09/19
II. Architecture: Summary Basic. Level Handler extends Application Logger extends Topical. Logger. Factory uses Object. Web Consortium manages extends (Mono. Log) - D 10 - 2001/09/19
Roles: Role Handler Empty Logger Log methods Topical. Logger Manages Handler & topic Logger. Factory Provides Logger Aims: èApplication uses the interface for the instrumentation èInterface names represent clearly the inheritance structure èRespect the java log terminology Object. Web Consortium (Mono. Log) - D 11 - 2001/09/19
II. Architecture: comparaison with java log & log 4 j monolog Java log Log 4 j Handler Appender Logger Category Log. Manager Category. Factory Logger Topical. Logger. Factory Aspect separation Object. Web Consortium (Mono. Log) - D 12 - 2001/09/19
III. Intrumentation(1/2): header èImports import org. objectweb. util. monolog. api. Basic. Level; import org. objectweb. util. monolog. api. Logger. Factory; èGet the Monitor Logger. Factory lf = … // component initialisation static Logger l = lf. get. Logger(“org. ow. toto”); èBoolean to delete instrumentation code at compilation time static boolean trace = true; //false Object. Web Consortium (Mono. Log) - D 13 - 2001/09/19
III. Instrumentation (2/2) èIn source code if ( trace && l. is. Loggable(Basic. Level. DEBUG) ) l. log(Basic. Level. DEBUG, . . . ); or if ( m. is. Loggable(Basic. Level. DEBUG) ) l. log(Basic. Level. DEBUG, . . . ); or l. log(Basic. Level. DEBUG, . . . ); Object. Web Consortium (Mono. Log) - D 14 - 2001/09/19
IV. Log 4 j & Java. Log wrapper èEasy levels mapping èEasy methods mapping èEasy unique name mapping èOne Logger. Factory by wrapper èMust implement multiple name property Object. Web Consortium (Mono. Log) - D 15 - 2001/09/19
V. Packaging èPackage name Øorg. objectweb. util. monolog. api Øorg. objectweb. util. monolog. wrapper. log 4 j Øorg. objectweb. util. monolog. wrapper. javalog èJars Øow_util_log_api. jar Øow_util_log_wrp_log 4 j. jar do not integrated to objectweb project Øow_util_log_wrp_ java. Log. jar Object. Web Consortium (Mono. Log) - D 16 - 2001/09/19
- Slides: 16