Log4j2 JDBC Appender DriverManager write to SQLite FAIL. #2911
-
DescriptionLog4j2 JDBC Appender DriverManager write to SQLite FAIL. ConfigurationVersion: 2.21.1 Operating system: Ubuntu 20.04 JDK: OpenJDK Runtime Environment Temurin-21.0.3+9 Database: org.xerial sqlite-jdbc 3.46.0.0 Logs
Reproductionlog4j2.xml
sqlite.sqlcreate SQLite db:
Run Application , log
Error Message:
My JDBC App Test
Log4j2 JdbcDatabaseManager's use of setNString causes writing to SQLIte to fail. Is it possible to use setString for SQLIte instead of setNString?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
The deleted comments were an attempt to disseminate malware. |
Beta Was this translation helpful? Give feedback.
-
Sure, since the JDBC driver does not support the optional <JDBC name="demo-db-appender" tableName="logs">
<DriverManager driverClassName="org.sqlite.JDBC"
connectionString="jdbc:sqlite:/home/demo/sqlite_data/demologs.db"/>
<Column name="timestamp" isEventTimestamp="true"/>
<Column name="loglevel" pattern="%p" isUnicode="false"/>
<Column name="message" pattern="%m" isUnicode="false"/>
<Column name="exception" pattern="%ex" isUnicode="false"/>
<Column name="thread" pattern="%t" isUnicode="false"/>
</JDBC> Alternatively you can use the <JDBC name="demo-db-appender" tableName="logs">
<DriverManager driverClassName="org.sqlite.JDBC"
connectionString="jdbc:sqlite:/home/demo/sqlite_data/demologs.db"/>
<ColumnMapping name="timestamp" columnType="java.util.Date"/>
<ColumnMapping name="loglevel" pattern="%p"/>
<ColumnMapping name="message" pattern="%m"/>
<ColumnMapping name="exception" pattern="%ex"/>
<ColumnMapping name="thread" pattern="%t"/>
</JDBC> |
Beta Was this translation helpful? Give feedback.
@life888888,
Sure, since the JDBC driver does not support the optional
setNString()
method, you just need to set theisUnicode
configuration attribute ofColumn
to false (cf.Column
plugin reference).