10

How can I shut down the Stanford CoreNLP messages (see end of post)? I first tried setting log4j.category.edu.stanford=OFF in log4j.properties but that didn't help so I found out that apparently it uses a nonstandard logging framework called "Redwood". According to http://nlp.stanford.edu/nlp/javadoc/javanlp/there is a documentation but it is password protected. I tried RedwoodConfiguration.empty().apply(); but that doesn't help either.

The logging messages:

Adding annotator tokenize
Adding annotator ssplit
Adding annotator pos
Loading default properties from tagger edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger
Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [1,2 sec].

P.S.: Redwood.hideAllChannels(); also doesn't work. The following however suppresses my own logging statement (but not the ones from StanfordCoreNLP):

RedwoodConfiguration.empty().apply();
Redwood.log("test redwood");

Solution Ok, StevenC was right, it weren't logging statements after all but the default initialization messages are written to stderr which I was not expecting seeing that Stanford has it's own logging framework and then doesn't use it :-)

Anyways, his hints led me to discover this solution:

// shut off the annoying intialization messages
RedwoodConfiguration.empty().captureStderr().apply();
nlp = new StanfordCoreNLP(myproperties);
// enable stderr again
RedwoodConfiguration.current().clear().apply();
Frakcool
  • 10,915
  • 9
  • 50
  • 89
Konrad Höffner
  • 11,100
  • 16
  • 60
  • 118
  • 4
    I couldn't find the `captureStderr()` method, so I used the following line `RedwoodConfiguration.empty().capture(System.err).apply()` instead of yours. Works perfectly. – Enkk Dec 15 '15 at 17:55
  • I have less comments but still I have some remaining : May 12, 2017 2:36:04 PM edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor appendRules INFO: Read 83 rules May 12, 2017 2:36:04 PM edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor appendRules INFO: Read 267 rules May 12, 2017 2:36:04 PM edu.stanford.nlp.ling.tokensregex.CoreMapExpressionExtractor appendRules INFO: Read 25 rules – Nicolas Henin May 12 '17 at 18:39
  • Those INFO messages are via Redwood and can be muted by the methods given at: https://stackoverflow.com/questions/41761099/mute-stanford-corenlp-logging – Christopher Manning Jan 31 '18 at 01:07

3 Answers3

3

You can also find the Redwood Tutorial PDF on GitHub in the Redwood project.

The url is in this page: https://github.com/gangeli/redwood/blob/master/doc/tutorial.pdf

(Obviously, I can't tell you if the documents are the same, 'cos I don't know the username / password either :-) )


Taking this a bit further, the Tutorial PDF I linked to really just a slide show. If you want documentation of the properties file, the best I could find was the javadocs for the RedwoodConfiguration.parse method. And in fact, the rest of that classes javadoc is probably the best doc that you will find ... short of reading the source code.

Warning ... there are indications that the free-standing Redwood code on GitHub may be different to the version in the NLP codebase.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • 1
    All I want to do is just to shut off logging :-) – Konrad Höffner Feb 18 '14 at 14:45
  • You could always read the source code (for the NLP embedded version) ... :-) – Stephen C Feb 18 '14 at 16:21
  • 1
    Actually, are you sure those are logging messages, and not random `System.out` or `System.err` messages? The Redwood logging config API allows you to capture those message and send them to the logs. And of course, you should be able to send the logs to "/dev/null" or some such. This is in the javadocs. – Stephen C Feb 18 '14 at 16:24
  • `RedwoodConfiguration.current().clear().apply(); StanfordCoreNLP pipeline = new StanfordCoreNLP(props);` works perfectly for me. – Om Prakash May 19 '17 at 08:31
3

StanfordNLP uses Redwood as logging framework for logging. You have to disable it before initializing StanfordNLP pipeline.

import edu.stanford.nlp.util.logging.RedwoodConfiguration;
RedwoodConfiguration.current().clear().apply();
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);

It works for me. It does not show lengthy INFO message in every line, while running program.

Hope it helps!

Om Prakash
  • 2,675
  • 4
  • 29
  • 50
0

This can be resolved by setting blank Output Stream to System error stream.

Please see my answer in similar thread https://stackoverflow.com/a/48743963/1303210

FatalError
  • 922
  • 12
  • 31