This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I am trying to use the log4j JDBC appender with mySQL. I am getting below error message: log4j:ERROR Could not create an Appender. Reported error follows. java.lang.ClassNotFoundException: org.apache.log4j.jdbcplus.JDBCAppender at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClass Loader.java:199) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClass Loader.java:224) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302) at java.lang.Class.forName0(Native Method)
I have put the log4j jar file in the classpath. My log4j configuration is as below: <appender name="JDBC" class="org.apache.log4j.jdbcplus.JDBCAppender"> <param name="url" value="jdbc:mysql://localhost:3306/mysql" /> <param name="username" value="root" /> <param name="password" value="root" /> <param name="sql" value="INSERT INTO LOGTEST (id, prio, cat, thread, msg) VALUES (@INC@, '@PRIO@', '@CAT@', '@THREAD@', '@MSG@')" /> <param name="buffer" value="1" /> <param name="commit" value="true" /> <param name="dbclass" value="com.mysql.jdbc.Driver" /> <param name="quoteReplace" value="true" /> <param name="throwableMaxChars" value="3000" /> <param name="layoutPartsDelimiter" value="#-#" /> <layout class="org.apache.log4j.PatternLayout"> <!-- conversion pattern with 4 parts separated by #-#, second part is empty --> <param name="ConversionPattern" value="[%t] %m#-##-#%d{dd.MM.yyyy}#-#%d{HH:mm:ss}" /> </layout> </appender>
Can someone please help me out what am I doing wrong?
Thanks, Trupti
trupti nigam
Ranch Hand
Joined: Jun 21, 2001
Posts: 602
posted
0
now I am getting below exception: java.sql.SQLException: No suitable driver at java.sql.DriverManager.getConnection(DriverManager.java:532) at java.sql.DriverManager.getConnection(DriverManager.java:171) at org.apache.log4j.jdbc.JDBCAppender.getConnection(JDBCAppender.java:19 7)
There was some mistake in the earlier configuration. I corrected that so am getting above exception.
Thanks, Trupti
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35249
7
posted
0
Is the MySQL JDBC driver in your classpath? That's the error you would get if it wasn't.
The driver is in the classpath, but the configuration had lower case driver name. I changed so do not get that error any more but now it seems I have problem with my SQL statement.
The statement runs with no problem from mySQL console but when I run it through the config file I get below error:
log4j:ERROR Failed to excute sql java.sql.SQLException: You have an error in your SQL syntax; check the manual th at corresponds to your MySQL server version for the right syntax to use near '[E xecuteThread: '1' for queue: 'weblogic.kernel.System'] Entering net.mycompany.' at line 1
The SQLstatement is given below: <param name="sql" value="INSERT INTO test (message) VALUES ('%d - %c - %p - %m'); "/>
Can someone please let me know what is wrong in above SQL?