Sebastian G.
Sebastian G.

Reputation: 636

Cannot disable ORMLites Logging

So, my problem is:

I need to disable ORMLites Logging.

I already tried

System.setProperty(LocalLog.LOCAL_LOG_LEVEL_PROPERTY, "ERROR");

On a JavaFX Application, this worked. But now I have a console program where this doesnt want to work... First theory I have is:

I am using an seperate Logger with a FileHandler. Does this maybe interfere with LocalLog? Setting the property works, but this does no change to the output.

Edit: Regarding differences between the both projects:

I use commons logging in the non-FX Project. Could this be the reason why it isnt working? (I use it because of commons csv and commons configuration... not for logging)

Upvotes: 4

Views: 700

Answers (2)

Gray
Gray

Reputation: 116888

I am using an separate Logger with a FileHandler. Does this maybe interfere with LocalLog? Setting the property works, but this does no change to the output.

ORMLite tries to detect and use other logging libraries if available. I suspect that it is finding another logging implementation and use it. You can force it to use one logger however with:

System.setProperty("com.j256.ormlite.logger.type", "LOCAL");

or

-Dcom.j256.ormlite.logger.type=LOCAL

Then you can set the log level with:

System.setProperty("com.j256.ormlite.logger.level", "ERROR");

or

-Dcom.j256.ormlite.logger.level=ERROR

Upvotes: 7

Sebastian G.
Sebastian G.

Reputation: 636

Ok, I found the culprit:

Apache Commons Logging seems to cause an issue somewhere.... Not sure why, but removing it solved the issue.

If Gray has an explanation for this, i will mark his answer as the solved one. But for now I have my problem solved.

EDIT: If you still need Commons.Logging for your Application to work, you can use this:

System.setProperty("org.apache.commons.logging.Log",
     "org.apache.commons.logging.impl.NoOpLog");

This removed all the messages from ORMLite.

Upvotes: 1

Related Questions