Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-3145

Cannot see JDBC error message

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.14.1
    • None
    • Appenders
    • None
    • Important

    Description

      I got error:
      2021-08-25 04:47:30,272 Thread-6 ERROR Unable to write to database [JdbcManager{name=DB_LOG, bufferSize=0, tableName=public.medside_log, columnConfigs=[

      { name=Date, layout=null, literal=null, timestamp=true }, { name=Level, layout=%-5level, literal=null, timestamp=false }, { name=Source, layout=%logger{36}, literal=null, timestamp=false }, { name=Message, layout=%message, literal=null, timestamp=false }, { name=instance, layout=first-real-DEBUG, literal=null, timestamp=false }, { name=stacktrace, layout=%exception, literal=null, timestamp=false }], columnMappings=[]}] for appender [DB_LOG]. org.apache.logging.log4j.core.appender.AppenderLoggingException: Error writing to JDBC Manager 'JdbcManager{name=DB_LOG, bufferSize=0, tableName=public.medside_log, columnConfigs=[{ name=Date, layout=null, literal=null, timestamp=true }

      ,

      { name=Level, layout=%-5level, literal=null, timestamp=false }

      , { name=Source, layout=%logger

      {36}, literal=null, timestamp=false }, { name=Message, layout=%message, literal=null, timestamp=false }, { name=instance, layout=first-real-DEBUG, literal=null, timestamp=false }, { name=stacktrace, layout=%exception, literal=null, timestamp=false }], columnMappings=[]}': JDBC connection not available [columnConfigs=[{ name=Date, layout=null, literal=null, timestamp=true }, { name=Level, layout=%-5level, literal=null, timestamp=false }

      , { name=Source, layout=%logger
      {36}

      , literal=null, timestamp=false }, { name=Message, layout=%message, literal=null, timestamp=false }, { name=instance, layout=first-real-DEBUG, literal=null, timestamp=false }, { name=stacktrace, layout=%exception, literal=null, timestamp=false }], sqlStatement=insert into public.medside_log (Date,Level,Source,Message,instance,stacktrace) values (?,?,?,?,?,?), factoryData=FactoryData [connectionSource=jdbc:postgresql://localhost:5432/DBLogger, tableName=public.medside_log, columnConfigs=[{ name=Date, layout=null, literal=null, timestamp=true }, { name=Level, layout=%-5level, literal=null, timestamp=false }, { name=Source, layout=%logger

      {36}

      , literal=null, timestamp=false },

      { name=Message, layout=%message, literal=null, timestamp=false }

      ,

      { name=instance, layout=first-real-DEBUG, literal=null, timestamp=false }

      ,

      { name=stacktrace, layout=%exception, literal=null, timestamp=false }

      ], columnMappings=[], immediateFail=false, retry=true, reconnectIntervalMillis=5000, truncateStrings=true], connection=null, statement=null, reconnector=Reconnector [latch=java.util.concurrent.CountDownLatch@54af7da2[Count = 0], shutdown=false], isBatchSupported=true, columnMetaData=null]

      ----------------------------------------
      Impossible to understand problem.
      Only when I debug log4j2 source code, I managed to find real SQLException :

      log4j-core-2.14.1-sources.jar!/org/apache/logging/log4j/core/appender/db/jdbc/JdbcDatabaseManager.java

              public void run() {
                  while (!shutdown) {
                      try {
                          sleep(factoryData.reconnectIntervalMillis);
                          reconnect();
                      } catch (final InterruptedException | SQLException e) {
                          logger().debug("Cannot reestablish JDBC connection to {}: {}", factoryData, e.getLocalizedMessage(),
                                  e);
                      } finally {
                          latch.countDown();
                      }
                  }
              }
      

      SQLException was
      ERROR: java.lang.ClassNotFoundException: org.postgresql.Driver

      after I added driver
      ERROR: column "date" does not exist

      From previos "big" error
      sqlStatement=insert into public.medside_log (Date,Level,Source,Message,instance,stacktrace) values (?,?,?,?,?,?)
      Date - with uppercase but real insert was with lowercase.

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            tnikolai Nicolai Timofeev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: