0

Hi I am trying to use db for access logging in my tomcat application.

I followed tomcat documentation. https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/valves/JDBCAccessLogValve.html

The server seems to boot up fine but I don't see any entries created in the table. But I could see that tomcat is picking up the connection parameters (If I give invalid connection parameters, the server does not boot up)

This is my server.xml config for access logging

    <Valve className="org.apache.catalina.valves.JDBCAccessLogValve"
           driverName="com.mysql.jdbc.Driver"
           connectionURL="jdbc:mysql://localhost:3306/test?user=root"
          pattern="combined" resolveHosts="false" tableName="access" />

I am using the combined pattern and the table created has the exact schema as specified in the documentation -

CREATE TABLE access (
id INT UNSIGNED AUTO_INCREMENT NOT NULL,
remoteHost CHAR(15) NOT NULL,
userName CHAR(15),
timestamp TIMESTAMP NOT NULL,
virtualHost VARCHAR(64) NOT NULL,
method VARCHAR(8) NOT NULL,
query VARCHAR(255) NOT NULL,
status SMALLINT UNSIGNED NOT NULL,
bytes INT UNSIGNED NOT NULL,
referer VARCHAR(128),
userAgent VARCHAR(128),
PRIMARY KEY (id),
INDEX (timestamp),
INDEX (remoteHost),
INDEX (virtualHost),
INDEX (query),
INDEX (userAgent)
);

Catalina.out does not seem to log any information useful to this context.

PS I understand that DB logging has a lot of failure points but my application's primary db is the same as this one. So the failure point is kind of shared.

1 Answer 1

0

You need to define user name and password as separate sub-element tags, not through the connection url.

Like:

  <Valve className="org.apache.catalina.valves.JDBCAccessLogValve"  
    driverName="com.mysql.jdbc.Driver"
    connectionURL="jdbc:mysql://localhost:3306/testdbName"
    connectionName="root"
    connectionPassword=""/>

For debugging you can try the "Request Dumper Valve" to see what exactly is going on. See: http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#Request_Dumper_Filter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.