I have been trying to configure p3spy logging system on my maven based spring project.But each time when i try to configure p3spy differently. i get always errors.
Here is my following settings
I placed p6spy-2.3.0.jar, spy.properties and mysql-connector-java-5.1.17.jar inside the tomcat/lib directory.
tomcat/context.xml
<Resource auth="Container"
driverClassName="com.mysql.jdbc.Driver"
name="jdbc/myDataSource"
type="javax.sql.DataSource"
url="jdbc:p6spy:mysql://localhost:3306/coexi?useUnicode=true&characterEncoding=utf-8"
username="root"
password=""
maxActive="100"
maxIdle="50" />
while using this above settings.. it gives me this following error..
Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:p6spy:mysql://localhost:3306/coexi?useUnicode=true&characterEncoding=utf-8' java.sql.SQLException: No suitable driver
Here i also tried to replacce few settings inside this resources.
<Resource auth="Container"
driverClassName="com.p6spy.engine.spy.P6SpyDriver"
name="jdbc/myDataSource"
type="javax.sql.DataSource"
url="jdbc:p6spy:mysql://localhost:3306/coexi?useUnicode=true&characterEncoding=utf-8"
username="root"
password=""
maxActive="100"
maxIdle="50" />
And by using this code, getting this following error:
Cannot instantiate com.p6spy.engine.logging.appender.Log4jLogger, even on second attempt. java.lang.ClassNotFoundException: com.p6spy.engine.logging.appender.Log4jLogger
main/config/PersistanceConfiguration
@Bean
public DataSource dataSource() {
Context ctx;
try {
ctx = new InitialContext();
return (DataSource) ctx.lookup("java:comp/env/jdbc/myDataSource");
} catch (NamingException e) {
LOGGER.info("Error to find the database : \"java:comp/env/jdbc/myDataSource\".");
}
return null;
tomcat/lib/spy.properties
driverlist=com.mysql.jdbc.Driver
deregisterdrivers=true
includecategories=info, statement
excludecategories=info,debug,result,batch
logfile = /Users/coexi/Documents/spy.log
append=true
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=p6spy - %m%n
log4j.logger.p6spy=INFO,STDOUT
/main/resources/logback.xml
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<appender name="GEN_FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${catalina.base}/logs/general.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>gen_%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<category name="com.p6spy">
<priority value="INFO" />
</category>
<logger name="org.hibernate.SQL" additivity="false" >
<level value="DEBUG" />
<appender-ref ref="SQLROLLINGFILE" />
</logger>
<logger name="org.hibernate.type" additivity="false" >
<level value="TRACE" />
<appender-ref ref="SQLROLLINGFILE" />
</logger>
<root level="info">
<appender-ref ref="STDOUT" />
</root>
<root level="error">
<appender-ref ref="ERRORS_FILE"/>
</root>
main/resources/log4j.xml.backend
<?xml version="1.0" encoding="UTF-8" ?>
http://jakarta.apache.org/log4j/'>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="INFO" />
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<category name="com.p6spy">
<priority value="INFO" />
</category>
<logger name="org.hibernate.SQL" additivity="false" >
<level value="DEBUG" />
<appender-ref ref="SQLROLLINGFILE" />
</logger>
<logger name="org.hibernate.type" additivity="false" >
<level value="TRACE" />
<appender-ref ref="SQLROLLINGFILE" />
</logger>
<root>
<level value="INFO" />
<appender-ref ref="console" />
</root>
Fullstack error.
http://pastebin.com/3LpgtPtr