MoSKito ships with embedded support for major Logging frameworks, in particular log4j, java.util.logging and, for lazy people, System.outs. In order to attach a logger to a StatsProducer, follow the steps below:
Please note, MoSKito 2.3.0 comes with SLF4J instead of LOG4J.
Create a logger
Moskito comes with two built-in 'loggers', the IntervalStatsLogger and the DefaultStatsLogger.
The IntervalStatsLogger can be attached to an Interval, the DefaultStatsLogger attaches itself to StatsProducer, that can't be reset. Both are connecting to the internal IntervalUpdateService and monitor interval updates. As soon as the IntervalUpdate is fired, they read the current state of the Producer they are attached to and send it to the LogOutput.
Below is an example of how to configure and attach a log4j logger to any producer:
Attaching a log4j logger to a MoSKito producer is only half of the work, you still need to tell log4j where to log it.
Below is an example that creates local files for each interval and logs into them:
What else you might want to know
- The DefaultStatsLogger logs throughout 60 seconds. The IntervalStatsLogger logs at the end of the interval.
- The LogLevel is info.