简体   繁体   中英

Disable ORMLite logs when using log4j 2.13

I am using log4j:2.13 and ORMLite:5.1

I cannot figure out how to disable (or change level) of ORMLite logs without affecting the level of logs on the rest of my application.

ORMLite's documenation states that I should do the following: log4j.logger.com.j256.ormlite=DEBUG (source)

Well this doesn't seem to work. I am new to using log4j. Does anyone know the solution?

Here is my log4j2.properties file:

status = error
name = PropertiesConfig

filters = threshold

filter.threshold.type = ThresholdFilter
filter.threshold.level = debug

appenders = console

appender.console.type = Console
appender.console.name = STDOUT
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

rootLogger.level = debug
rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = STDOUT

# Even if I set this to ERROR, log4j continues logging at debug level because I set it above..
log4j.logger.com.j256.ormlite.level = ERROR

No matter what log level I try, it seems that rootLogger.level takes priority and "overrides" the ormlite setting.

Often such problem is caused by the fact that there is more than one Log4J config file in the class path. The first found config is used. Some other file could have been found earlier than yours.

What can you do? Analyze you class path, all JARs in the class path, all directories (if any) in the class path. If in doubt, check in debugger what config file was used.

Update

The line with log4j.logger is not correct. Change it as follows (set other logger name if you wish):

logger.ormlite.name = com.j256.ormlite
logger.ormlite.level = error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM