eclipse-archived / californium.core

Californium project
86 stars 69 forks source link

Logging #9

Open mkovatsc opened 10 years ago

mkovatsc commented 10 years ago

How to do logging and how to improve it? There are two types of logging for Californium:

  1. Internal logging to get the Californium implementation right. This is usually only of interest for the Californium team and when developing extensions. For now, we just use java.utils.logging here, which is not great, but there is also no alternative that stands out.
  2. Operational logging to see what is going on. This is what users of Californium want to have in their logs. For this, it is best to disable the internal logging completely and use MessageInterceptors (see MessageTracer as example implementation). Just implement your preferred logger in a custom Interceptor and add it to the Endpoint. It will receive then log every message that enters and leaves the system. Additional custom logging could be done in your CoapResource implementations.

To improve this concept, it would be great to know if there are other things that are interesting during operation.

In the long-run, we might also want to change the internal logger. Maybe we can align the logger implementation over multiple IoT Eclipse projects or at least find something that is good for all Californium committers.

sophokles73 commented 8 years ago

The first thing to do would be to migrate to SLF4J API. We can then better integrate into existing environments by means of letting the user decide which logging framework to use (there are bindings for almost all existing frameworks available). Furthermore, SLF4J's API supports the use of Markers that can be used to label log messages and use these labels for filtering (given that the underlying logging framework supports Markers). This way operational logging could be achieved by means of adding a particular Marker, e.g. operational when logging a message. In the logging configuration the user can then decide what to log and at what level.