owlcs / owlapi

OWL API main repository
822 stars 315 forks source link

Question: How to configure OWLAPI logging "from outside" #1015

Closed rpgoldman closed 2 years ago

rpgoldman commented 3 years ago

I'm using a system that is built on API: Owlery. As a user of that system, how would I control the logging that is done by OWLAPI? I'd like to diagnose some problems Owlery is having loading my ontology, but I don't see any log output at all.

Is there some -D argument I could add when starting up Owlery that would filter through to OWLAPI and result in logging?

I have tried groveling around in the code and docs, but I'm not much of a Java person, and so I'm not finding the information I need. Thanks!

ignazio1977 commented 3 years ago

OWLAPI uses SLF4J to manage its logging levels, you can configure it by adding a file to the classpath like the one in https://github.com/owlcs/owlapi/blob/version5/contract/src/test/resources/simplelogger.properties (in this example the logging is turned off, as this is for the unit test suite)

All other methods supported by SLF4J are supported.

Note that SLF4J requires a runtime dependency to be added - i.e., it needs to find one of its adaptors on the classpath. This is to allow an application using this library (and the OWLAPI) to decide for themselves which logging implementation to use. If none is available, the only logged message will be that SLF4J cannot find an adaptor and therefore no OWLAPI logging will be outputted. See http://www.slf4j.org/manual.html for more details.

rpgoldman commented 3 years ago

@ignazio1977 -- Thank you so much for that answer.

Would the following entries in the classpath be enough to get OWLAPI logging to work:

org.slf4j.slf4j-log4j12-1.7.30.jar

and

org.slf4j.slf4j-log4j12-1.7.30.jar

I have been starting the external program (Owlery) with the following options:

-Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG -Dorg.slf4j.simpleLogger.logFile=/srv/owlery.log

... but still not seeing logs.

I suppose something somewhere else could be clobbering these options, but nothing I see suggests that there are other settings.

ignazio1977 commented 3 years ago

Did you mean one of the entries to be slf4j-api? You've mentioned the log4j adaptor twice.

The command line arguments look correct to me but I haven't tried that method, the config file works for sure - I've used it often during testing.

rpgoldman commented 3 years ago

Sorry about that: I botched my cut-and-paste. The other library jar file was supposed to be log4j.log4j-1.2.17.jar