-1

I'm new to the concepts ontology and inferencing. I have an ontology saved in .owl format. My target is to load the .owl file using jena API in netbeans 7.4, inference it to grab the required information from the ontology. I followed the documentation given in jena site(https://jena.apache.org/documentation/ontology ). So far I tried to load the .owl file to netbeans using the following code set.

String path = "C:/datafiles/wine.owl";
Model model = FileManager.get().loadModel("file:" + path);
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
InfModel infmodel = ModelFactory.createInfModel(reasoner, model);

But I get this error.

log4j:WARN No appenders could be found for logger  (org.apache.jena.riot.stream.JenaIOEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

How do I fix this?

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • possible duplicate of [No appenders could be found for logger(log4j)?](http://stackoverflow.com/questions/12532339/no-appenders-could-be-found-for-loggerlog4j) – Joshua Taylor Mar 12 '14 at 12:49
  • This doesn't have anything to do with Jena in particular. If you search for "No appenders could be found for logger" on Google or on Stack Overflow, you get *lots* of results that describe what's happening and how to address it. – Joshua Taylor Mar 12 '14 at 12:50

1 Answers1

2

Jena uses log4j for logging. As the message says you need to initialize log4j properly. Have you followed the link in the message?

If you don't initialize log4j, you will miss out on logging but your program should still run. You can initialize log4j by either

A)
Providing a configuration file called log4j.properties. If you use maven or maven-like project structure put it in src/java/resources/ and log4j will pick it up. The contents of the file should look something like

log4j.rootLogger=INFO, stdlog
log4j.appender.stdlog=org.apache.log4j.ConsoleAppender
log4j.appender.stdlog.layout=org.apache.log4j.PatternLayout
log4j.appender.stdlog.layout.conversionPattern=%d{HH:mm:ss,SSS} - %c{1}:%L - %m%n`

Follow the link in the message and learn about log4j so you can put together a config file that fits your needs.

or

B)
Calling LogCtl.setCmdLogging(); in your code to use the configuration Jena uses for the command line (which may or may not be good for your purposes). F.i. you can put that in a static {} code block in your main class.

jjaderberg
  • 9,844
  • 34
  • 34