0

I'm using DBUnit to run some tests in Java. I have put this in my code before I kick off the test:

Logger.getLogger("org.dbunit").setLevel(Level.OFF);

Which stops logging to the console in Eclipse. However when I run this jar from a windows console I see this string of text print out to the console over and over again

SLF4J: org.dbunit.database.ForwardOnlyResultSetTable
SLF4J: org.dbunit.dataset.AbstractTable
SLF4J: org.dbunit.dataset.AbstractTableMetaData
SLF4J: org.dbunit.dataset.datatype.StringDataType
SLF4J: org.dbunit.database.ForwardOnlyResultSetTable
SLF4J: org.dbunit.dataset.AbstractTable
SLF4J: org.dbunit.dataset.AbstractTableMetaData
SLF4J: org.dbunit.dataset.datatype.StringDataType
SLF4J: org.dbunit.database.ForwardOnlyResultSetTable
SLF4J: org.dbunit.dataset.AbstractTable
SLF4J: org.dbunit.dataset.AbstractTableMetaData
SLF4J: org.dbunit.dataset.datatype.StringDataType
SLF4J: org.dbunit.database.ForwardOnlyResultSetTable
SLF4J: org.dbunit.dataset.AbstractTable
SLF4J: org.dbunit.dataset.AbstractTableMetaData

What can I do to get this to stop printing to the console?

Current Log4j config:

log4j.rootLogger=ERROR, file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.Threshold=ERROR
log4j.appender.file.File=test.log
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.logger.org.dbunit=ERROR
jymbo
  • 1,335
  • 1
  • 15
  • 26
  • 1
    Which logger implementation do you use? Most allow to add a log config file that shuts off logging. – Henry Dec 05 '18 at 04:43
  • Its log4j, I have a log4j.properties file. But w/e combination of configs I use doesn't seem to stop it: Adding my current config to the question. – jymbo Dec 05 '18 at 16:36
  • By setting the log level to `OFF` you should disable all logging (see also https://stackoverflow.com/questions/571960/disabling-log4j-output-in-java). If this does not work, there is something other wrong with your logger setup. And indeed the log messages don't look like they are coming from log4j. – Henry Dec 06 '18 at 05:18

0 Answers0