opsin icon indicating copy to clipboard operation
opsin copied to clipboard

StatusLogger messages printed to console by opsin-core

Open jasondbiggs opened this issue 2 years ago • 1 comments

I use opsin-core-2.6.0-jar-with-dependencies.jar as a library within a larger application. When that application is launched from the command line, I get this message printed to the command line the first time opsin is loaded:

ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. 
Using SimpleLogger to log to the console...

I want to suppress that message. I don't want to include any additional logging libraries. Is this possible?

jasondbiggs avatar Jun 21 '22 20:06 jasondbiggs

As far as I'm aware there is not an idiomatic way of supressing this message other than adding a logging implementation to the classpath

If you're accessing OPSIN programmatically a kludge might be to do something like:

PrintStream _err = System.err;
try (OutputStream os = new OutputStream() {
	public void write(int b) {
	}
}; PrintStream ps = new PrintStream(os)) {
	System.setErr(ps);
	NameToStructure.getInstance();
} catch (IOException e) {
	e.printStackTrace();
} finally {
	System.setErr(_err);
}

i.e. temporarily redirect standard error to a no-op output

dan2097 avatar Jun 23 '22 19:06 dan2097