I'm logging my application's logs into database using JDBCAppender of log4j. At some point, I get "MySQLSyntaxErrorException" and I'm trying to find out the cause.
Here is my log4j.properties file;
# Define the DB appender
log4j.appender.DB=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.DB.URL=jdbc:mysql://.../...
log4j.appender.DB.driver=com.mysql.jdbc.Driver
log4j.appender.DB.user=...
log4j.appender.DB.password=...
log4j.appender.DB.sql=INSERT INTO logs (EventDate,Level,Logger,Location,Message) VALUES( '%d{yyyy-MM-dd HH:mm:ss.SSS}', '%p' , '%c' ,'Test', '%m')
log4j.appender.DB.layout=org.apache.log4j.PatternLayout
And here is my table;
When I run my project I'm getting following error;
log4j:ERROR Failed to excute sql com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''.
If I change '%m' parameter with anything else, no exception occurs and log is inserted into DB successfully. So, I think the problem is with the message itself here but I cannot find out which message is causing it since it's a real huge project.
Is there any way that I can see the actual SQL statement? Or is there anything else that I can do to debug this more?