Configuring Slf4JLogger in p6spy-2.1.1

719 views
Skip to first unread message

Vivek S

unread,
Sep 24, 2014, 3:14:40 PM9/24/14
to p6spy-de...@googlegroups.com
Hello,
 I was earlier using the older version of p6spy.
I was using the Log4j setting in the spy.properties, as follow:
appender=com.p6spy.engine.logging.appender.Log4jLogger
log4j.appender.STDOUT=org.apache.log4j.RollingFileAppender
log4j.appender.STDOUT.File=/logs/spyLog4j.log
log4j.appender.STDOUT.MaxFileSize=100MB
log4j.appender.STDOUT.MaxBackupIndex=10
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=%m%n
log4j.logger.p6spy=INFO,STDOUT

I am not sure how to migrate to Slf4JLogger in 2.1.1.
I have made the following changes:

1. In spy.properties, have changed the appender as Slf4JLogger:
appender=com.p6spy.engine.spy.appender.Slf4JLogger
2. Added p6spy-2.1.1-log4j-nodep.jar to class path
3. Retained all other settings as it is, for log4j in spy.properties.

However, I dont even find the spyLog4j.log being created, in logs folder.
I am new to Slf4j. Please bear with my question.

Can someone please throw some light on this one?
Regards
Vivek

Quinton McCombs

unread,
Sep 24, 2014, 10:46:35 PM9/24/14
to p6spy Developers on behalf of Vivek S
To use slf4j, you will need to have slf4j-api and the appropriate bridge library available on the classpath.  The bridge library is the interface between slf4j-api and the actual logging implementation such as log4j, logback, etc.  For example, to use log4j as the logging framework, you would need slf4j-api, slf4j-log4j12, and log4j on your classpath. See the slf4j docs for further details on this.

p6spy-2.1.1-log4j-nodep.jar contains p6spy, slf4j-api, slf4j-log4j12, and log4j all in the same jar file.  If you already have slf4j-api and slf4j-log4j on your classpath (hibernate uses slf4j as do many other popular open source projects), then you should use p6spy-2.1.1.jar instead to avoid having potentially different versions of slf4j on your classpath.

When using the slf4j appender in p6spy, you should remove all of the log4j configuration from spy.properties.  The slf4j appender will write log messages using log4j which is already configured by your application.  All that you need to do it configure the "p6spy" category.  All of the log messages will be written at INFO level.

For a concrete example of configuring the logging using the slf4j appender, see the 'appenders' section of the configuration guide.


--
You received this message because you are subscribed to the Google Groups "p6spy Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to p6spy-develope...@googlegroups.com.
To post to this group, send email to p6spy-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/p6spy-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/p6spy-developers/e4b5651a-7024-46c2-a3cc-9ecde6e2cab9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vivek S

unread,
Sep 25, 2014, 8:14:27 AM9/25/14
to p6spy Developers on behalf of Quinton McCombs
Thanks for the clarification.
Now I am able to use the slf4j logger on top of Log4j.
Just needed some more clarification:
1. I am not seeing any resultset/result getting printed out,even though I have not set any filters(filter=false) OR set the excludecategories.
How to get resultset printed in the latest p6spy jar?

2. Regarding the message format, as per the documentation on the website, I see it as:
current time|execution time|category|statement SQL String|effective SQL string
The output actually printed is:
25-09-14 17:21:26:700|0|statement|connection 7|select jobtrigger0_.JobSpec_ID as JobSpec10_1404_1_, from JobTrigger jobtrigger0_ where jobtrigger0_.JobSpec_ID=84085

I see in the place "statement SQL String" as connection 7. What does this field indicate?
Also, is the execution time printed in seconds? Can that be changed to ms?

Regards
Vivek


--
You received this message because you are subscribed to a topic in the Google Groups "p6spy Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/p6spy-developers/v7399iRE7aw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to p6spy-develope...@googlegroups.com.

To post to this group, send email to p6spy-de...@googlegroups.com.
Visit this group at http://groups.google.com/group/p6spy-developers.

Quinton McCombs

unread,
Sep 25, 2014, 1:13:45 PM9/25/14
to p6spy-de...@googlegroups.com


On Thursday, September 25, 2014 7:14:27 AM UTC-5, Vivek S wrote:
Thanks for the clarification.
Now I am able to use the slf4j logger on top of Log4j.
Just needed some more clarification:
1. I am not seeing any resultset/result getting printed out,even though I have not set any filters(filter=false) OR set the excludecategories.
How to get resultset printed in the latest p6spy jar?


The default value for exclude categories is 'info,debug,result,resultset,batch'.  To see resultset and result categories, you will need to add the following to your spy.properties.

excludecategories=info,debug,batch



2. Regarding the message format, as per the documentation on the website, I see it as:
current time|execution time|category|statement SQL String|effective SQL string
The output actually printed is:
25-09-14 17:21:26:700|0|statement|connection 7|select jobtrigger0_.JobSpec_ID as JobSpec10_1404_1_, from JobTrigger jobtrigger0_ where jobtrigger0_.JobSpec_ID=84085

I see in the place "statement SQL String" as connection 7. What does this field indicate?
Also, is the execution time printed in seconds? Can that be changed to ms?


- The extra column is the connection id.  This is a sequentially generated identifier assigned to each connection.  It is used to identify the connection on which the activity was logged.
- The execution time is measured in milliseconds.

Note: I just corrected updated the docs.  The web site should get updated in the next hour or so,

 
Regards
Vivek


To unsubscribe from this group and stop receiving emails from it, send an email to p6spy-developers+unsubscribe@googlegroups.com.
To post to this group, send email to p6spy-developers@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "p6spy Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/p6spy-developers/v7399iRE7aw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to p6spy-developers+unsubscribe@googlegroups.com.
To post to this group, send email to p6spy-developers@googlegroups.com.

Vivek S

unread,
Sep 25, 2014, 11:35:36 PM9/25/14
to p6spy Developers on behalf of Quinton McCombs
Thanks once again for the quick update. I need some more clarification on the way the statements are logged.
On a connection, if I am executing a batch of SQL commands, do all the statements get logged in the Log4J assigned log file.
I had not enabled the property "autoflush   = true". 
If I enable this, would all the statements in a SQL prepared using "java.sql.PreparedStatement.addBatch()"
and executed using: java.sql.Statement.executeBatch() get logged.
What I observed is that only one statement in that batch was showing up. I still need to cross check this once more.

Regards
Vivek

To unsubscribe from this group and all its topics, send an email to p6spy-develope...@googlegroups.com.
To post to this group, send email to p6spy-de...@googlegroups.com.

Vivek S

unread,
Sep 26, 2014, 4:09:58 AM9/26/14
to p6spy Developers on behalf of Quinton McCombs
Hi,
 I just now confirmed the issue. When I try executing the batch, only the last one in the batch is getting logged 
rather than the entire list of staments in that batch. Is there a way to print all the statements which are getting executing in the same batch?

Regards
Vivek

Peter Butkovic

unread,
Sep 26, 2014, 5:16:18 AM9/26/14
to p6spy-de...@googlegroups.com
Hi,

how about using:
excludecategories=info,debug

instead of
excludecategories=info,debug,batch

does that help?

Dňa piatok, 26. septembra 2014 10:09:58 UTC+2 Vivek S napísal(-a):
Hi,
 I just now confirmed the issue. When I try executing the batch, only the last one in the batch is getting logged 
rather than the entire list of staments in that batch. Is there a way to print all the statements which are getting executing in the same batch?

Regards
Vivek
On Fri, Sep 26, 2014 at 9:05 AM, Vivek S <vivek...@gmail.com> wrote:
Thanks once again for the quick update. I need some more clarification on the way the statements are logged.
On a connection, if I am executing a batch of SQL commands, do all the statements get logged in the Log4J assigned log file.
I had not enabled the property "autoflush   = true". 
If I enable this, would all the statements in a SQL prepared using "java.sql.PreparedStatement.addBatch()"
and executed using: java.sql.Statement.executeBatch() get logged.
What I observed is that only one statement in that batch was showing up. I still need to cross check this once more.

Regards
Vivek
To unsubscribe from this group and all its topics, send an email to p6spy-developers+unsubscribe@googlegroups.com.

To post to this group, send email to p6spy-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/p6spy-developers.

Vivek S

unread,
Sep 26, 2014, 5:44:13 AM9/26/14
to p6spy Developers on behalf of Peter Butkovic
Hi,
 Yes that one helped.
Thanks a lot for the support.

Regards
Vivek

To unsubscribe from this group and all its topics, send an email to p6spy-develope...@googlegroups.com.
To post to this group, send email to p6spy-de...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages