j256 / ormlite-core

Core ORMLite functionality that provides a lite Java ORM in conjunction with ormlite-jdbc or ormlite-android
http://ormlite.com/
ISC License
577 stars 212 forks source link

LogBackendType must not use warning message (Unable to get new instance of class) #225

Closed JayDi85 closed 2 years ago

JayDi85 commented 2 years ago

Regression bug from #202: https://github.com/j256/ormlite-core/blob/02cc64cb6f9a251222b17c4c3b33f33f7b2f8940/src/main/java/com/j256/ormlite/logger/LogBackendType.java#L106

Ormlite tries to find first available logger system and print WARNING message to the logs on each fail. That's wrong (it's a standard use case). You must print warning message at the end of the cycle (if nothing found, not on each try) or change it to INFO level.

Example: ormlite successfully finds log4j, but print warning messages for another tries on app startup:

2021-10-03 17:24:51,409 [WARNING] ANDROID Unable to get new instance of class com.j256.ormlite.android.AndroidLogBackend$AndroidLogBackendFactory, so had to use local log: com.j256.ormlite.android.AndroidLogBackend$AndroidLogBackendFactory
2021-10-03 17:24:51,418 [WARNING] LOG4J2 Unable to get new instance of class com.j256.ormlite.logger.Log4j2LogBackend$Log4j2LogBackendFactory, so had to use local log: org/apache/logging/log4j/LogManager
JayDi85 commented 2 years ago

Workaround: increase logging level of LogBackendType classes by ormliteLocalLog.properties file in app's resources (example):

LogBackendType.*=ERROR
j256 commented 2 years ago

For the record @JayDi85, I merged in the latest code from SimpleLogging which had already fixed this issue.