You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2021/08/25 12:15:00 UTC
[jira] [Commented] (LOG4J2-3145) Cannot see JDBC error message
[ https://issues.apache.org/jira/browse/LOG4J2-3145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17404387#comment-17404387 ]
Gary D. Gregory commented on LOG4J2-3145:
-----------------------------------------
I suppose this should be an error log event, not a debug one. You can always set status to DEBUG in the log4j configuration element to see the current message.
> Cannot see JDBC error message
> -----------------------------
>
> Key: LOG4J2-3145
> URL: https://issues.apache.org/jira/browse/LOG4J2-3145
> Project: Log4j 2
> Issue Type: Bug
> Components: Appenders
> Affects Versions: 2.14.1
> Reporter: Nicolai Timofeev
> Priority: Major
>
> 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
> {code: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();
> }
> }
> }
> {code}
> 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.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)