-
Notifications
You must be signed in to change notification settings - Fork 12
Logging
las2peer provides a global static logging class i5.las2peer.logging.L2pLogger. This logger extends the java.util.logging.Logger class and can be configured through it's interface. The actual static object is kept private to preserve inconsistent or unintended modifications. The L2pLogger class does not provide a constructor, but a factory method. It's recommended to instantiate a L2pLogger for each of your class by inserting the following code at the beginning of your class.
private final L2pLogger logger = L2pLogger.getInstance(YourClassName.class.getName());
- By default the logger creates a log directory "./log/" and logs with log level FINEST to the default log file "log/las2peer.log".
- As mentioned the logger supports the Java native Log Levels. Please see Level.
- Log rotation is done. Currently it uses up to 10 files with max 1 MB each.
- Furthermore all logging output with INFO or higher is written to console (stderr). This way stdout is clean for developer defined output and the logging output may be filtered by system or external programs. Last but not least this is in compliance with the las2peer shell interactive mode.
Special Events can be logged and later analysed with the monitoring service. To publish a monitoring event please use the static L2pLogger.logEvent(...) methods. These special events are also written to the log file with log level FINER. This way they don't appear on the console with default levels. Since monitoring requires a las2peer context, it's only possible to log events from inside a L2pThread, which should be usually the case for a las2peer service. You can use the following line as a template:
L2pLogger.logEvent(Event.SERVICE_CUSTOM_MESSAGE_X, Context.getCurrent().getMainAgent(), "Provide here some information that can be evaluated");
For different events just replace X with a different number. The logged data can be evaluated by the Monitoring Service by an xml file containing the specified success_model. These models contain of six different categories (System Quality, Information Quality, Use, User Satisfaction, Individual Impact and Community Impact).
Template of a success_model;
<SuccessModel name="Name of your success model" service="your.service.name@version">
<dimension name="System Quality">
<factor name="No Factors or Measures yet">
</factor>
</dimension>
<dimension name="Information Quality">
<factor name="No Factors or Measures yet">
</factor>
</dimension>
<dimension name="Use">
<factor name="No Factors or Measures yet">
</factor>
</dimension>
<dimension name="User Satisfaction">
<factor name="No Factors or Measures yet">
</factor>
</dimension>
<dimension name="Individual Impact">
<factor name="No Factors or Measures yet">
</factor>
</dimension>
<dimension name="Community Impact">
<factor name="No Factors or Measures yet">
</factor>
</dimension>
</SuccessModel>
A factor can be specified by a measure.
<factor name="Factorname">
<measure name="Your measurement"/>
</factor>
The Monitoring Service needs a SQL statement for that measurement.
<measure name="Your measurement">
<query name="countOfMessageX">
SELECT COUNT(*) as number FROM monitoringTable.MESSAGE
WHERE EVENT = 'SERVICE_CUSTOM_MESSAGE_X' AND SOURCE_AGENT = '$SERVICE$'
</query>
<visualization type="KPI">
<operand name="countOfMessageX" index="0"/>
</visualization>
</measure>
You can use multiple queries. For the visualization just increase the index of the operand and match the name of the operand with the associated query. The queries are stored in the measurement catalog.
A Node, Service or Connector may want to use it's own log file. Therefore it has to instantiate the L2pLogger and define a log file. To do so one just calls setLogfilePrefix(String) on its logger instance. The static L2pLogger instance still keeps logging to default file and console. This can be changed using L2pLogger.setGlobalLogfilePrefix() and L2pLogger.setGlobalLogfileDirectory() methods.