aspose file tools*
The moose likes Other Open Source Projects and the fly likes jdbcappender log4j:ERROR Failed to excute sql Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "jdbcappender log4j:ERROR Failed to excute sql" Watch "jdbcappender log4j:ERROR Failed to excute sql" New topic
Author

jdbcappender log4j:ERROR Failed to excute sql

Rolley Jain
Greenhorn

Joined: Apr 10, 2012
Posts: 2
Hi all,

My log4j.xml file has the following code:

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



<appender name="JDBC" class="org.apache.log4j.jdbc.JDBCAppender">
<param name="driver" value="com.mysql.jdbc.Driver"/>
<param name="URL" value="jdbc:mysql://localhost:3306/LOGSDB"/>
<param name="user" value="root"/>
<param name="password" value="root"/>
<param name="sql" value="INSERT INTO LOGS(USER_ID,DATED,LOGGER,LEVEL,MESSAGE) VALUES('%x' , '%d{yyyy-MM-dd}' , '%C', '%p' , '%m')"/>
<layout class="org.apache.log4j.PatternLayout"/>
</appender>

<logger name="log4j.rootLogger" additivity="false">
<level value="debug,info"/>
<appender-ref ref="JDBC"/>
</logger>

<root>
<priority value="debug"></priority>
<appender-ref ref="JDBC" />
</root>

</log4j:configuration>

And when i run it it gives me following error:

log4j:ERROR Failed to excute sql
com.mysql.jdbc.exceptions.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 'Debug' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:930)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2864)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1567)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1659)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3112)
at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1307)
at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1226)
at org.apache.log4j.jdbc.JDBCAppender.execute(JDBCAppender.java:218)
at org.apache.log4j.jdbc.JDBCAppender.flushBuffer(JDBCAppender.java:290)
at org.apache.log4j.jdbc.JDBCAppender.append(JDBCAppender.java:186)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:251)
at org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:66)
at org.apache.log4j.Category.callAppenders(Category.java:206)
at org.apache.log4j.Category.forcedLog(Category.java:391)
at org.apache.log4j.Category.debug(Category.java:260)
at com.nyc.hhs.common.LogInfo.Debug(LogInfo.java:26)
at obe.coherence.SimpleCacheTest1.doGet(SimpleCacheTest1.java:52)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3717)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)


Can some one please point out the issue my code must be having?
 
 
subject: jdbcappender log4j:ERROR Failed to excute sql