Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 837
Sebastian G. Avatar asked Mar 11 '23 14:03

Sebastian G.


2 Answers

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
like image 69
Gray Avatar answered Mar 21 '23 06:03

Gray


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.

like image 29
Sebastian G. Avatar answered Mar 21 '23 07:03

Sebastian G.