Announcement Announcement Module
Collapse
No announcement yet.
How to Disable Annoying JDBC Informational Messages? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to Disable Annoying JDBC Informational Messages?

    I am using the Springframework JDBC interfaces and I am running Websphere 5.1 and Servlets. I have tried everything I can think of to disable the following messages:

    [3/17/05 18:59:28:484 EST] 323a0589 SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFact ory Database product name found in cache for DataSource [com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@5f41059 6]. Name is 'Oracle'.

    [3/17/05 19:35:32:500 EST] 5260c588 SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFact ory Looking up default SQLErrorCodes for DataSource

    Can you please explain how I go about disabling these messages on a system wide level or at least change the Spring logging level to WARN? I get thousands of these every day.

    Many thanks,

    IP

  • #2
    In your log4j.properties file in WEB-INF:

    log4j.logger.org.springframework=WARN

    I set my root logger to warn as well:
    log4j.rootLogger=WARN, logfile

    Comment


    • #3
      I am using XML Log4j initialization (it supports asynchronous processing). See below:

      <?xml version="1.0" encoding="UTF-8" ?>
      <!DOCTYPE log4j:configuration>

      <log4j:configuration threshold="warn" debug="false">

      <appender name="ASync" class="org.apache.log4j.AsyncAppender">
      <appender-ref ref="Console"/>
      <appender-ref ref="Main"/>
      </appender>

      <appender name="Console" class="org.apache.log4j.ConsoleAppender">
      <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
      </layout>
      </appender>

      <!-- logs will roll at midnight by default -->
      <appender name="Main" class="org.apache.log4j.DailyRollingFileAppender">
      <param name="file" value="test.log"/>
      <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p [%t] %c{1} - %m%n"/>
      </layout>
      </appender>

      <appender name="Severe" class="org.apache.log4j.DailyRollingFileAppender">
      <param name="threshold" value="ERROR"/>
      <param name="file" value="test_severe.log"/>
      <layout class="org.apache.log4j.PatternLayout">
      <param name="ConversionPattern" value="%d %-5p [%t] %c{1} %x - %m%n"/>
      </layout>
      </appender>

      </log4j:configuration>


      How would I disable the Spring Informational messages using XML instead of log4j.logger.org.springframework=WARN in a log4j.properties file as per the file above?

      Thanks again,

      IP

      Comment


      • #4
        Code:
        <category name="org.springframework">
            <priority value="WARN"/>
        </category>
        If you want to be more selective, add more of the package path to the name.

        HTH

        Comment


        • #5
          I added the category parameter to my Servlet initialization XML file but when ever my Servlet accesses the database I still get the following messages (I accessed my Servlet 4 times):

          [3/22/05 9:30:30:578 EST] 6bd78988 SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFact ory Looking up default SQLErrorCodes for DataSource
          [3/22/05 9:30:30:578 EST] 6bd78988 SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFact ory Database product name found in cache for DataSource [com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@5d2c499 7]. Name is 'Oracle'.
          [3/22/05 9:30:31:141 EST] 6bd78988 SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFact ory Looking up default SQLErrorCodes for DataSource
          [3/22/05 9:30:31:141 EST] 6bd78988 SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFact ory Database product name found in cache for DataSource [com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@5d2c499 7]. Name is 'Oracle'.
          [3/22/05 9:30:31:672 EST] 6bd78988 SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFact ory Looking up default SQLErrorCodes for DataSource
          [3/22/05 9:30:31:672 EST] 6bd78988 SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFact ory Database product name found in cache for DataSource [com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@5d2c499 7]. Name is 'Oracle'.
          [3/22/05 9:30:33:656 EST] 510ec988 SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFact ory Looking up default SQLErrorCodes for DataSource
          [3/22/05 9:30:33:656 EST] 510ec988 SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFact ory Database product name found in cache for DataSource [com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@5d2c499 7]. Name is 'Oracle'.

          Thanks,

          IP

          Comment


          • #6
            The logging pattern looks to me like WebSphere's default logging pattern. I don't think your config is getting picked up. Are you using commons-logging in your code?

            If so, then in the WAR file, create a META-INF/services directory and place a file in there with the filename org.apache.commons.logging.LogFactory

            The content of the file should be a single line; org.apache.commons.logging.impl.Log4jFactory

            Re-deploy the app and see if that helps.

            Comment


            • #7
              I tried that but I just want to recap what I did (or have have done). I am running a Servlet which initializes Log4j using an log4jConfig.xml file (see contents above). The XML file is within the WAR file. It does this as follows

              Logger log = Logger.getLogger("MyLogger")
              ....
              inputStream = context.getClass().getResourceAsStream("log4jConfi g.xml");
              InputStreamReader reader = new InputStreamReader(inputStream);
              DOMConfigurator conf = new DOMConfigurator();
              conf.doConfigure(reader, log.getLoggerRepository());

              I have no problem with my Log4j application messages doing this.

              Now to get rid of the SPring Informational messages added the category statement to my "log4jConfig.xml" file. I also created the "META-INF/services" sub-directory in my servlet WAR and created the file in the /services sub-directory called "org.apache.commons.logging.LogFactory" and put "org.apache.commons.logging.impl.Log4jFactory" as the only contents.

              I still get the Informational Spring messages as per my previous note everytime I access my Servlet. Should I be doing something in WebSphere to disable these messages as opposed to something in my application log4j configuration file?


              Thanks,

              IP

              Comment


              • #8
                Originally posted by iprentice
                I also created the "META-INF/services" sub-directory in my servlet WAR and created the file in the /services sub-directory called "org.apache.commons.logging.LogFactory"
                This will make no difference if you're not using commons-logging in your code, which it seems you're not.

                Originally posted by iprentice
                Should I be doing something in WebSphere to disable these messages as opposed to something in my application log4j configuration file?
                If application logging is correctly configured, these entries should not appear in the console/system logs. This happens as a default if no other logging mechanism is setup for your applications. I still think that the logging is not being correctly configured at an application level somewhere.

                However, you can modify the WAS logging levels via the admin console in Troubleshooting>Logs and Trace>[your server]>JVM Logs

                hth,

                Comment


                • #9
                  [3/17/05 18:59:28:484 EST] 323a0589 SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFact ory Database product name found in cache for DataSource [com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@5f41059 6]. Name is 'Oracle'.

                  [3/17/05 19:35:32:500 EST] 5260c588 SQLErrorCodes I org.springframework.jdbc.support.SQLErrorCodesFact ory Looking up default SQLErrorCodes for DataSource

                  Can you please explain how I go about disabling these messages on a system wide level or at least change the Spring logging level to WARN? I get thousands of these every day.
                  I think there's been lots of good advice already on the logging config side, so I won't go there. You can certainly turn this output off.

                  However, the last bit ("thousands per day") suggests to me that you may be using Spring JDBC a bit inefficiently.These informational messages occur when you create a new exception translator--typically, the result of creating a new JdbcTemplate. They show that Spring is getting a connection to ask for the database metadata to initialize its exception translation facility, which understands DBMS-specific error codes.

                  Actually, JdbcTemplate is threadsafe. You shouldn't create hosts of them: e.g. one per request. You should use one and share it. For example, your DAO might take a dataSource by DI and create a single shared JdbcTemplate like this:
                  Code:
                  public void setDataSource&#40;DataSource ds&#41; &#123;
                      this.jdbcTemplate = new jdbcTemplate&#40;ds&#41;;
                  &#125;
                  Then you can use that JdbcTemplate concurrently and you will have had exactly one lookup (and log output) when the DAO instance was configured. Assuming it's a singleton in the Spring context, which it normally should be.

                  Comment


                  • #10
                    You were absolutely correct. I wasn't reusing my instance of JdbcTemplate - I created a new instance every time I accessed the database. I modified my code to reuse the instance of JdbcTemplate and I only get the messages once in the log and everything works fine.

                    Many many thanks for you help.

                    Ian Prentice

                    Comment

                    Working...
                    X