0

My application is using Spring to handle the interaction with database (Sql Server)

And commons-logging-1.1.1.jar, log4j-1.2.17.jar, slf4j-api-1.6.3.jar and slf4j-log4j12-1.7.6.jar are put into build path for the logging framework of the application.

The last two logging jar (slf4j-api and slf4j-log4j12) are for another component inside the application to use log4j.

Here is my questions:

  1. When Spring-Jdbc runtime excecption happens, the exception is only showed in the console of eclipse with the font color red. The exception is NOT logged into the log file. But the normal log (like log.info(...)) are all in the log file. Why can't the run-time exception be in the log file and how to solve this problem.

  2. When I use SimpleJdbcCall to call the stored procedure with parameters in MapSqlParameterSource, the following log shows up:

14:43:30 [INFO ] Added default SqlReturnUpdateCount parameter named #update-count-1

14:43:30 [INFO ] Added default SqlReturnUpdateCount parameter named #update-count-1 ......

It's really annoying because the number of this message is so large. I want to turn off this particular log message without affecting another logging with the same level (INFO)

And my log4j.xml is fine I think because the logging are basically fine except the above issues.

macemers
  • 2,194
  • 6
  • 38
  • 55

1 Answers1

0
  1. Spring is using commons-logging internally that's why you can see the messages in your eclipse console. To redirect commons-logging to slf4j/log4j you need to remove commons-logging-1.1.1.jar from your classpath and add jcl-over-slf4j.jar from your slf4j version. To get rid of the dublicate red eclipse messages (jul and jcl) you can set the logging level in logging.properties for the console handler to warning:

    java.util.logging.ConsoleHandler.level = WARNING

  2. Second issue was solved here.

Community
  • 1
  • 1
Stefan
  • 12,108
  • 5
  • 47
  • 66