Alignment API: Logging

The documentation of SLF4J is comprehensive and explain very well what logging is and how it can be configured.

The implementation of the Alignment API uses logging though SLF4J.

What this means for the user is:

First run

The first command-line run should look like that:

$ java -cp lib/procalign.jar fr.inrialpes.exmo.align.cli.ParserPrinter file:examples/rdf/newsample.rdf -o /tmp/toto.rdf SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

This is actually fine. This means that no looger has been provided to the system and that all logging instructions will be ineffective.

Getting log messages

To get log messages, it is necessary to:

None is provided by the alignment API, because it is not the philosophy of logging.

As an example, one may use logback. For that purpose, the files logback-core-VERS.jar and logback-classic-VERS.jar have to be added to the classpath.

The result of the first command-line will be:

$ java -cp lib/slf4j/logback-core-1.0.9.jar:lib/slf4j/logback-classic-1.0.9.jar:lib/procalign.jar fr.inrialpes.exmo.align.cli.ParserPrinter file:examples/rdf/newsample.rdf -o /tmp/toto.rdf 17:10:37.578 [main] DEBUG f.i.exmo.align.parser.XMLParser - startElement XMLParser : RDF 17:10:37.581 [main] DEBUG f.i.exmo.align.parser.XMLParser - content XMLParser : 17:10:37.581 [main] DEBUG f.i.exmo.align.parser.XMLParser - startElement XMLParser : Alignment 17:10:37.588 [main] DEBUG f.i.exmo.align.parser.XMLParser - content XMLParser : 17:10:37.588 [main] DEBUG f.i.exmo.align.parser.XMLParser - startElement XMLParser : xml 17:10:37.588 [main] DEBUG f.i.exmo.align.parser.XMLParser - content XMLParser : yes 17:10:37.588 [main] DEBUG f.i.exmo.align.parser.XMLParser - endElement XMLParser : xml 17:10:37.588 [main] DEBUG f.i.exmo.align.parser.XMLParser - content XMLParser : ...
The warning is not displayed anymore, but the logging messages sent by the Alignment parser are now visible (and there are many).

Controling output

This output can be controlled easily through configuration file. For instance, if one puts this minimal configuration file logback.xml:

<configuration>
  <root level="OFF"/>
</configuration>
in the current directory, then the result of the command line is:
$ java -cp lib/slf4j/logback-core-1.0.9.jar:lib/slf4j/logback-classic-1.0.9.jar:lib/procalign.jar:lib/procalign.jar:. fr.inrialpes.exmo.align.cli.ParserPrinter file:examples/rdf/newsample.rdf -o /tmp/toto.rdf
Note the "." added at the end of the class path for telling where to find the logback.xml file.

From here the fun starts. Logging can be fully configured at the level of messages, classes, and packages. By simply modifying the configuration file, one can selects which messages to receive. This is worth mastering!


http://alignapi.gforge.inria.fr/logging.html

$Id: logging.html 1975 2014-10-31 16:28:17Z euzenat $