This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring Boot in Practice and have Somnath Musib on-line!
See this thread for details.
Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Log4J Configuration Issue

 
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to integrate log4j logging to an existing MYSQL-based struts application and am running into a configuration issue with how I have log4j configured in my system. I have a basic requirement to log messages to a system_log table. Basically, I did the following:

1) Created a SYSTEM_LOG table in my database with one column (MESSAGES which is a VARCHAR2(1000)).
2) Put the log4j jar file in the WEB-ING/lib directory.
3) Created a log4j.properties file that sits in the usual classes directory (with all my other properties files). This file looks like the following:

log4j.rootLogger=DEBUG, R
log4j.appender.R=org.apache.log4j.jdbc.JDBCAppender
log4j.appender.R.driver=com.mysql.jdbc.Driver
log4j.appender.R.URL=jdbc:mysql://localhost/product
log4j.appender.R.user=user
log4j.appender.R.password=password
log4j.appender.R.sql=INSERT INTO SYSTEM_LOG (Message) VALUES ('%c - %p - %m')
log4j.appender.R.layout=org.apache.log4j.PatternLayout




I get the following error when I startup Tomcat:

java.sql.SQLException: 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 'taglib'')' at line 1

I believe my SQL syntax is correct in the properties file, but I'm not sure why there is an error and certainly not sure where 'taglib' comes into play.

Does anyone have any ideas on this?

Thanks,
Scott
 
Marshal
Posts: 27288
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't tell if your SQL syntax is correct because you can't see the SQL that is being executed. All you can see is a template that is being used to generate the SQL. So presumably it is generating SQL that is not valid.

To see it, perhaps you could also write your data to a file-based appender in the same format. My guess is that unescaped quotes are messing up what you think is your correct SQL, but that's just a guess.
 
Scott Updike
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Another interesting note is that when I look at the table specified in my log4j setup, there are about 1000+ records in it that Tomcat has saved. So I know that the database setup is correct (since it found the database, table, and column), but I still get the error stated above as Tomcat is starting up. Here is a sample of the records that I'm seeing in the database table:

org.apache.commons.digester.Digester.sax - DEBUG - ignorableWhitespace( )
org.apache.commons.digester.Digester.sax - DEBUG - startElement(,,attribute)
org.apache.commons.digester.Digester - DEBUG - Pushing body text '
org.apache.commons.digester.Digester.sax - DEBUG - ignorableWhitespace( )
org.apache.commons.digester.Digester.sax - DEBUG - startElement(,,name)
org.apache.commons.digester.Digester - DEBUG - Pushing body text '
org.apache.commons.digester.Digester.sax - DEBUG - characters(arg3)
org.apache.commons.digester.Digester.sax - DEBUG - endElement(,,name)
org.apache.commons.digester.Digester - DEBUG - Popping body text '
org.apache.commons.digester.Digester.sax - DEBUG - ignorableWhitespace( )
org.apache.commons.digester.Digester.sax - DEBUG - startElement(,,required)
org.apache.commons.digester.Digester - DEBUG - Pushing body text '
org.apache.commons.digester.Digester.sax - DEBUG - characters(false)
org.apache.commons.digester.Digester.sax - DEBUG - endElement(,,required)


Does this look familiar to anyone? I still don't know why I'm getting a SQL syntax error when there are so many records written to the database.

Please help!

Thanks,
Scott
 
reply
    Bookmark Topic Watch Topic
  • New Topic