14 Commits

Author SHA1 Message Date
arthur_blake 2d8cbd4cdf update copyright message in headers 2008-04-12 02:51:44 +00:00
arthur_blake 21cbf688ec update/add copyright notice in build script and javadoc 2008-04-12 02:42:42 +00:00
arthur_blake 44043261af upgrade to slf4j 1.5.0 2008-04-12 02:38:26 +00:00
arthur_blake 86364a24fa update changes and web site to reflect 1.1 release 2008-04-12 02:37:44 +00:00
arthur_blake 4900e751bb upgrade to slf4j 1.5.0 2008-04-12 02:25:44 +00:00
arthur_blake 9da5241e39 remove beta designation from version number and fix scripts 2008-03-12 21:46:14 +00:00
arthur_blake ddbee4d1b6 add TODO entry about maven2 support 2008-03-12 21:45:31 +00:00
arthur_blake 6bf61ef02b minor bug fix; mark drivers as not found if they fail to load for ANY reason 2008-03-12 21:44:22 +00:00
arthur_blake 18c7e2fd19 minor javadoc generation fix 2007-11-11 01:13:47 +00:00
arthur_blake 339682f0c9 update news release link for 1.1 beta 1 release 2007-11-10 23:49:08 +00:00
arthur_blake b9ac53c3f3 update web site and documentation in preparation for 1.1 beta 1 release 2007-11-10 02:15:11 +00:00
arthur_blake 1695b42ce1 upgrade from slf4j 1.4.2 to 1.4.3 2007-11-10 02:12:00 +00:00
arthur_blake a072c4e953 added new debugging options log4jdbc.sqltiming.warn.threshold and log4jdbc.sqltiming.error.threshold (system property settings) 2007-11-09 03:48:42 +00:00
arthur_blake 567cefd156 added HSQLDB (org.hsqldb.jdbcDriver) and H2 (org.h2.Driver) to list of "well known" drivers that log4jdbc looks for at startup, prepare for 1.1 beta 1 release and correct scripts 2007-11-08 23:38:29 +00:00
44 changed files with 772 additions and 295 deletions
+38 -14
View File
@@ -1,29 +1,53 @@
2007-07-25 1.1 alpha 2 Release
2008-04-11 1.1 Release
o upgrade to SLF4J 1.5. Note that log4jdbc should still work with
any older (or newer) version of SLF4J too.
o slightly better fault tolerance for when loading/probing of
popular JDBC drivers fails for any reason.
2007-11-10 1.1 beta 1 Release
o added HSQLDB (org.hsqldb.jdbcDriver) and H2 (org.h2.Driver) to
list of "well known" drivers that log4jdbc looks for at startup.
o added log4jdbc.sqltiming.warn.threshold and
log4jdbc.sqltiming.error.threshold system property settings to
greatly aid in finding slow running sql. Special thanks to
Lilianne E. Blaze for the idea and initial implementation.
2007-07-25 1.1 alpha 2 Release
o JDBC 4.0 support!
o fix Null pointer exception bug that could happen with setObject call on PreparedStatementSpy
o fix Null pointer exception bug that could happen with setObject
call on PreparedStatementSpy
o added MySQL (com.mysql.jdbc.Driver) and PostgreSQL (org.postgresql.Driver)
to list of "well known" drivers that log4jdbc looks for at startup.
o added MySQL (com.mysql.jdbc.Driver) and PostgreSQL
(org.postgresql.Driver) to list of "well known" drivers that
log4jdbc looks for at startup.
2007-05-29 1.1 alpha 1 Release
o Fixed problem where when sql timing log was the only log turned on, log4jdbc would not recognize that
logging was on at all.
o Fixed problem where when sql timing log was the only log turned
on, log4jdbc would not recognize that logging was on at all.
o report sql exceptions in the sql timing log as well (when they occured during sql execution) and
prominently show that the sql FAILED, and display how long it tried to chug on the sql
before the exception was thrown
o report sql exceptions in the sql timing log as well (when they
occured during sql execution) and prominently show that the sql
FAILED, and display how long it tried to chug on the sql before
the exception was thrown.
o Switch to Simple Logging Facade for Java SLF4J instead of using log4j directly, so that any underlying
logging system can be easily used.
o Switch to Simple Logging Facade for Java SLF4J instead of using
log4j directly, so that any underlying logging system can be
easily used.
o option added to ant build script to generate javadoc with ydoc to include UML diagrams within the javadoc.
o option added to ant build script to generate javadoc with ydoc
to include UML diagrams within the javadoc.
o dump batched sql correctly.
o add simple command line program (PostLogProfilerProcessor) for processing sqltiming log files to create
a simple profiling report from log data.
o add simple command line program (PostLogProfilerProcessor) for
processing sqltiming log files to create a simple profiling
report from log data.
2007-04-21 Initial 1.0 Release
+1 -1
View File
@@ -1,6 +1,6 @@
log4jdbc is open source software, released under the Apache License, Version 2.0:
Copyright 2007 Arthur Blake
Copyright 2007-2008 Arthur Blake
Licensed under the Apache License, Version 2.0 (the "License");
you may not use log4jdbc except in compliance with the License.
+2
View File
@@ -16,3 +16,5 @@ o ALL String concatenation & dumping methods should take place ONLY if logging
o review dumpedSql method - make auto line breaking option (& num chars used) be options
o need log4jdbc.debug.stack.regex so that the stack matching can take place via regex
o maven2 repository support
+98 -33
View File
@@ -17,20 +17,24 @@
<a href="#news">news</a> |
<a href="#features">features</a> |
<a href="#usage">usage</a> |
<a href="#license">license</a> |
<a href="#advanced">advanced</a> |
<a href="#similiartools">similiar tools</a> |
<a href="#feedback">feedback</a>
<br>
<a href="apidocs-jdbc3/net/sf/log4jdbc/package-summary.html">javadoc(JDK1.4: JDBC 3)</a> |
<a href="apidocs-jdbc4/net/sf/log4jdbc/package-summary.html">javadoc(JDK1.6: JDBC 4)</a>
<a href="http://sourceforge.net/projects/log4jdbc/">sourceforge page</a> |
<a href="apidocs-jdbc3/net/sf/log4jdbc/package-summary.html">JDK1.4/JDBC 3 javadoc</a> |
<a href="apidocs-jdbc4/net/sf/log4jdbc/package-summary.html">JDK1.6/JDBC 4 javadoc</a>
</h1>
<p>
<b>log4jdbc</b> is a JDBC driver that can log SQL and/or JDBC calls (and optionally SQL timing information)
for other jdbc drivers using the <a target="slf4j" href="http://www.slf4j.org/">Simple Logging Facade For Java</a> (SLF4J) logging system.
<b>log4jdbc</b> is a Java JDBC driver that can log SQL and/or JDBC calls (and optionally SQL timing information)
for other JDBC drivers using the <a target="slf4j" href="http://www.slf4j.org/">Simple Logging Facade For Java</a> (SLF4J) logging system.
</p>
<h2><a name="news"/>news</h2>
<p class="left"><b>2007-07-25:</b> <a href="http://sourceforge.net/forum/forum.php?forum_id=719640">log4jdbc 1.1 alpha 2 released.</a> JDBC 4 support! See <a href="CHANGES">CHANGES</a> for all the release details.</p>
<p class="left"><b>2008-04-11:</b> <a href="http://sourceforge.net/forum/forum.php?forum_id=810350">log4jdbc 1.1 final release out!</a> See <a href="CHANGES">CHANGES</a> for all the release details.</p>
<p class="left"><b>2007-11-10:</b> <a href="http://sourceforge.net/forum/forum.php?forum_id=753559">log4jdbc 1.1 beta 1 released.</a> New optional timing threshold settings for honing in on slow SQL.</p>
<p class="left"><b>2007-07-25:</b> <a href="http://sourceforge.net/forum/forum.php?forum_id=719640">log4jdbc 1.1 alpha 2 released.</a> JDBC 4 support!</p>
<p class="left"><b>2007-05-29:</b> <a href="http://sourceforge.net/forum/forum.php?forum_id=700185">log4jdbc 1.1 alpha 1 released.</a> Most notable change is that the <a target="slf4j" href="http://slf4j.org">Simple Logging Facade for Java</a> is now used instead of <b>log4j</b> directly.
<p class="left"><b>2007-04-21:</b> <a href="http://sourceforge.net/forum/forum.php?forum_id=688372">log4jdbc 1.0 has been released!</a> Download it and give it a try!</p>
@@ -69,6 +73,11 @@ for other jdbc drivers using the <a target="slf4j" href="http://www.slf4j.org/">
<li>
Works with any underlying JDBC driver, with JDK 1.4 and above, and SLF4J 1.x.
</li>
<li>
Open source software, licensed under the business friendly <b>Apache 2.0 license:</b> <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
</li>
</ul>
<p class="right"><a href="#top">[back to top]</a></p>
<h2><a name="usage"/>usage</h2>
@@ -83,7 +92,7 @@ for other jdbc drivers using the <a target="slf4j" href="http://www.slf4j.org/">
<p>
Currently there are very few actual JDBC 4 drivers on the market. (The only major one that I really know about is Apache Derby aka The Java DB distributed with JDK 1.6.)
JDBC 4 support was added with the JDK 1.6 release and adds many additional features over and above JDBC 3.
However, the log4jdbc JDBC 4.0 driver can wrap a JDBC 3 or older driver and
However, the log4jdbc JDBC 4 driver can wrap a JDBC 3 or older driver and
it's recommended that if you use JDK 1.6 or above, that you use the log4jdbc JDBC 4 driver that is compiled with JDK 1.6.
</p>
<p>
@@ -96,10 +105,10 @@ for other jdbc drivers using the <a target="slf4j" href="http://www.slf4j.org/">
</p>
<pre>
Choose and <a href="http://sourceforge.net/project/showfiles.php?group_id=194500&package_id=229335&release_id=527690">download</a> one of the drivers .jar files:
Choose and <a href="http://sourceforge.net/project/showfiles.php?group_id=194500&package_id=229335&release_id=527690">download</a> one of the driver .jar files:
log4jdbc3-1.1alpha2.jar JDBC 3 support for JDK 1.4 , JDK 1.5
log4jdbc4-1.1alpha2.jar JDBC 4 support for JDK 1.6 , JDK 1.7
log4jdbc3-1.1beta1.jar JDBC 3 support for JDK 1.4 , JDK 1.5
log4jdbc4-1.1beta1.jar JDBC 4 support for JDK 1.6 , JDK 1.7
Place the log4jdbc jar that you choose into your application's classpath.
</pre>
@@ -123,7 +132,7 @@ for other jdbc drivers using the <a target="slf4j" href="http://www.slf4j.org/">
You will need two jars:
slf4j-api-1.4.2.jar (or the latest available version) and
slf4j-api-1.4.3.jar (or the latest available version) and
whichever jar you pick depending on the java logging system you choose
Place these two .jar files into your application's classpath.
@@ -144,14 +153,16 @@ for other jdbc drivers using the <a target="slf4j" href="http://www.slf4j.org/">
oracle.jdbc.driver.OracleDriver (Oracle)
com.sybase.jdbc2.jdbc.SybDriver (Sybase)
net.sourceforge.jtds.jdbc.Driver (SourceForge SQL Server driver)
net.sourceforge.jtds.jdbc.Driver (jTDS SQL Server & Sybase driver)
com.microsoft.jdbc.sqlserver.SQLServerDriver (Microsoft SQL Server driver)
weblogic.jdbc.sqlserver.SQLServerDriver (Weblogic SQL Server driver)
com.informix.jdbc.IfxDriver (Informix)
org.apache.derby.jdbc.ClientDriver (Apache Derby client/server driver)
org.apache.derby.jdbc.EmbeddedDriver (Apache Derby embedded driver)
org.apache.derby.jdbc.ClientDriver (Apache Derby client/server driver, aka the Java DB)
org.apache.derby.jdbc.EmbeddedDriver (Apache Derby embedded driver, aka the Java DB)
com.mysql.jdbc.Driver (MySQL)
org.postgresql.Driver (PostgresSQL)
org.hsqldb.jdbcDriver (HSQLDB pure Java database)
org.h2.Driver (H2 pure Java database)
</pre>
<p>
If you want to use a different underlying jdbc driver that is not already in the above supported list,
@@ -235,27 +246,76 @@ for other jdbc drivers using the <a target="slf4j" href="http://www.slf4j.org/">
this would be printed in the debug information, rather than the package name for a connection pool, object relational system, etc.
</p>
</li>
<li>Starting with the 1.1 alpha 1 release, a new tool was included which you can use to post-process sql timing logs produced by log4jdbc
to produce simple profiling reports with statistics and a dump of the sql statements that ran the slowest within the log.
To invoke the tool, use the profsql.sh (for unix/linux) and profsql.cmd (for windows) scripts located in the scripts
folder. These scripts take as one argument, the filename of a sql timing log (generated from the
<code>jdbc.sqltiming</code> log category. They produce a profiling report to stdout.
At this point the tool is experimental and I expect it to evolve quite a bit over the next few releases.
Nevertheless, it has already been very useful to me for tracking down SQL performance problems.
</li>
</ol>
<p class="right"><a href="#top">[back to top]</a></p>
<h2><a name="license"/>license</h2>
<p>
log4jdbc is open source software, licensed under the <b>Apache 2.0 license:</b> <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
</p>
<h2><a name="advanced"/>advanced</h2>
<ul class="left">
<li>A simple tool is included which you can use to post-process sql timing logs produced by log4jdbc.
It can output simple profiling reports with statistics and a dump of the sql statements that ran the slowest within the log.
To invoke the tool, use the profsql.sh (for unix/linux) and profsql.cmd (for windows) scripts located in the scripts
folder. These scripts take as one argument, the filename of a sql timing log (generated from the
<code>jdbc.sqltiming</code> log category. They produce a profiling report to stdout.
The tool is currently experimental and I expect it to evolve quite a bit over the next few releases.
Nevertheless, it has already been very useful to me for tracking down SQL performance problems.
</li>
<li>
Starting with the 1.1 beta 1 release, you can set timing thresholds to more easily find slow running SQL. These are set via system properties:
<p>
<code>-Dlog4jdbc.sqltiming.warn.threshold=&lt;number of milliseconds&gt;</code> causes SQL that takes &lt;number of milliseconds&gt; or more time to execute to be logged at the <b>warning</b> level in the sqltiming log.
</p>
<p>
<code>-Dlog4jdbc.sqltiming.error.threshold=&lt;number of milliseconds&gt;</code> causes SQL that takes &lt;number of milliseconds&gt; or more time to execute to be logged at the <b>error</b> level in the sqltiming log.
</p>
<p>
Note that the sqltiming log must be enabled at the warn or error log levels for these features to work. Also the logged output for both of these settings will log with debug information that is normally only shown
when the sqltiming log is enabled at the debug level. This can help you to more quickly find slower running SQL without adding overhead or logging for normal running
SQL that executes below the threshold level (if the logging level is set appropriately.)
</p>
</li>
</ul>
<p class="right"><a href="#top">[back to top]</a></p>
<h2><a name="similiartools"/>similiar tools</h2>
<h3>Some other tools and libraries that are similiar to log4jdbc.</h3>
<ul class="left">
<li>
<a target="othertool" href="http://www.p6spy.com/">P6Spy</a>
is probably the most well known JDBC logging driver but it hasn't been updated in about 4 years.
</li>
<li>
<a target="othertool" href="http://www.jahia.net/jahia/page597.html">SQL Profiler</a> an add-on for P6Spy, also about 4 years out of date.
</li>
<li>
<a target="othertool" href="http://zer0.free.fr/craftsman/spy.php">Craftsman Spy</a> appears to overlap quite a bit with the feature set in log4jdbc. This library hasn't been updated in 2 years and depends on Jakarta Commons Logging.
</li>
<li>
<a target="othertool" href="http://jamonapi.sourceforge.net/"> JAMon </a> (Java Application Monitor) is a comprehensive application monitor and monitoring API which includes JDBC/SQL monitoring as part of it's very large feature set.
</li>
<li>
<a target="othertool" href="http://sourceforge.net/projects/jdbcproxy/">JdbcProxy</a> is another sourceforge hosted project. The driver can also emulate another JDBC driver to test the application without a database
</li>
<li>
<a target="othertool" href="http://rkbloom.net/logdriver/index.html">LogDriver</a> appears to be similiar to log4jdbc and the author has written a nice <a target="othertool" href="http://java.sys-con.com/read/204723.htm">article</a> on JDBC logging in general and his motivation and experience of writing LogDriver.
</li>
</ul>
</p>
<p class="right"><a href="#top">[back to top]</a></p>
<h2><a name="feedback"/>feedback</h2>
<p>Feedback and suggestions would be greatly appreciated. Email me at arthur_blake at users.sourceforge.net</p>
<p>Feedback and suggestions would be greatly appreciated. Email me at <b>arthur_blake at users.sourceforge.net</b></p>
<p>Also, visit <a target="myblog" href="http://arthurblake.wordpress.com">my blog</a>.</p>
<p class="right"><a href="#top">[back to top]</a></p>
<h1>
@@ -264,15 +324,18 @@ log4jdbc is open source software, licensed under the <b>Apache 2.0 license:</b>
<a href="#news">news</a> |
<a href="#features">features</a> |
<a href="#usage">usage</a> |
<a href="#license">license</a> |
<a href="#advanced">advanced</a> |
<a href="#similiartools">similiar tools</a> |
<a href="#feedback">feedback</a>
<br>
<a href="apidocs-jdbc3/net/sf/log4jdbc/package-summary.html">javadoc(JDK1.4: JDBC 3)</a> |
<a href="apidocs-jdbc4/net/sf/log4jdbc/package-summary.html">javadoc(JDK1.6: JDBC 4)</a>
<a href="http://sourceforge.net/projects/log4jdbc/">sourceforge page</a> |
<a href="apidocs-jdbc3/net/sf/log4jdbc/package-summary.html">JDK1.4/JDBC 3 javadoc</a> |
<a href="apidocs-jdbc4/net/sf/log4jdbc/package-summary.html">JDK1.6/JDBC 4 javadoc</a>
<br>
<img class="logo" src="log4jdbc-logo-gray.png">
<img class="logo" src="log4jdbc-logo-gray.png"><br>
<p class="copyright">Copyright &copy; 2007-2008 <a href="http://arthur.blake.name">Arthur Blake</a></p>
</h1>
<p class="ad">
YourKit is kindly supporting open source projects with its full-featured Java Profiler.
YourKit, LLC is creator of innovative and intelligent tools for profiling
@@ -280,6 +343,8 @@ Java and .NET applications. Take a look at YourKit's leading software products:
<a href="http://www.yourkit.com/java/profiler/index.jsp">YourKit Java Profiler</a> and
<a href="http://www.yourkit.com/.net/profiler/index.jsp">YourKit .NET Profiler</a>.
</p>
<a href="http://sourceforge.net/projects/log4jdbc/"><img alt="sourceforge" title="log4jdbc sourceforge page" class="sflogo" src="sourceforge_whitebg.gif"></a>
</body>
</html>
+4 -2
View File
@@ -8,6 +8,7 @@
.usage {text-align:left;}
h1 {font-size:1em;color:#f06;background-color:#eee;display:block;padding:0.8em;}
h2 {font-size:1.2em;color:#f06;background-color:#eee;display:block;height:2em;padding-top:0.8em;}
h3 {font-size:1.1em;color:0;font-weight:bold;margin:5px;}
a {text-decoration:none;}
a:link {color: #f06;}
a:visited {color: #f06;}
@@ -25,6 +26,7 @@ code,pre {color:navy;background-color:beige;font-size:11pt;}
pre {border:2px dashed navy;margin-left:3em;margin-right:4em;margin-top:1em;margin-bottom:1em;white-space:pre-line;}
p.ad {font-size:1em;color:blue;}
.ad {font-size:0.8em;color:blue}
.copyright {font-size:0.8m;text-align:center}
.copyright a {color:#ef39e9}
.sflogo {float:right; margin-right:30px;}
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -11,7 +11,7 @@ call java -version
call ant -Djdbc.level=3 all
set JAVA_HOME=c:\jdk1.6.0
set JAVA_HOME=C:\jdk1.6.0_03
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin
call java -version
+28 -16
View File
@@ -1,23 +1,42 @@
<?xml version='1.0' encoding='ISO-8859-1' ?>
<!--
Ant build script for log4jdbc
Tested with Apache Ant version 1.6.5 & 1.7
built with jdk 1.4.2_13 (for use with jdbc3)
and/or jdk 1.6.0 (for use with jdbc4)
Copyright 2007-2008 Arthur Blake
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="log4jdbc" default="all" basedir="..">
<!-- the jdbc.level flag should be set externally to either 3 or 4
the is the jdbc version and should be 3 if using a jdk 1.4 (or 1.5) (1.4 is recommended for maximum compatibility)
this is the jdbc version and should be 3 if using a jdk 1.4 or 1.5 (jdk 1.4 is recommended for maximum compatibility)
the jdbc.level flag should be set to 4 if using a jdk 1.6 or greater.
defaults to jdbc3 build if not set externally
therefore to build both, ant should be invoked twice, setting the jdbc.level externally
to 3 and then 4. and using the jdk 1.4 and then 1.6.
-->
<property name="jdbc.level" value="3" />
@@ -29,23 +48,18 @@
<!-- release version -->
<property name="version" value="1.1alpha2"/>
<property name="version" value="1.1"/>
<target name="all" depends="cleancompile,compile,cleanjar,jar"/>
<!--
note that if jdbc.level is 3, a jdk 1.4 compiler should be used to build log4jdbc
and if the jdbc.level is 4, a jdk 1.6 compiler should be used to build log4jdbc
therefore to build both, ant should be invoked twice, setting the jdbc.level externally
to 3 and then 4. and using the jdk 1.4 and then 1.6.
jdbc.level is explicitly set here to xxx so that the user is forced to set it externally.
-->
<!-- ydoc.home.X is only used for the ydoc.X targets for producing javadoc with UML
The ydoc.home.3 and ydoc.home.4 properties are only used for the ydoc.3
and ydoc.4 targets for producing javadoc with UML
it requires the commercial ydoc utility (see http://www.yworks.com/en/products_ydoc.htm)
(use the javadoc target to generate regular javadoc)
it requires the commercial ydoc utility
(see http://www.yworks.com/en/products_ydoc.htm)
use the javadoc target to generate regular javadoc
ydoc.home.3 is for jdk1.4 / JDBC 3
ydoc.home.4 is for jdk1.6 / JDBC 4
@@ -194,7 +208,7 @@
<!-- note that the jdk source code is referenced here so that javadoc will be generated from
interface class methods when none is specified in the implementation -->
<sourcepath path="/jdk1.6.0/src"/>
<sourcepath path="/jdk1.6.0_03/src"/>
<link href="http://java.sun.com/javase/6/docs/api/"/>
<!--
<link href="http://java.sun.com/j2ee/1.4/docs/api/"/>
@@ -220,6 +234,4 @@
</doclet>
</javadoc>
</target>
</project>
+1 -1
View File
@@ -12,7 +12,7 @@ call java -version
call ant -Djdbc.level=3 ydoc.3
set JAVA_HOME=c:\jdk1.6.0
set JAVA_HOME=c:\jdk1.6.0_03
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin
call java -version
+2 -2
View File
@@ -2,7 +2,7 @@
rem *************************************************************************************************
rem * *
rem * Copyright 2007 Arthur Blake *
rem * Copyright 2007-2008 Arthur Blake *
rem * *
rem * Licensed under the Apache License, Version 2.0 (the "License"); *
rem * you may not use this file except in compliance with the License. *
@@ -25,4 +25,4 @@ rem * profiling output report.
rem * *
rem *************************************************************************************************
java -Xmx1024m -classpath ..\build\log4jdbc-1.1alpha1.jar net.sf.log4jdbc.PostLogProfilerProcessor %*
java -Xmx1024m -classpath ..\build\log4jdbc3-1.1.jar net.sf.log4jdbc.PostLogProfilerProcessor %*
+2 -2
View File
@@ -2,7 +2,7 @@
# *************************************************************************************************
# * *
# * Copyright 2007 Arthur Blake *
# * Copyright 2007-2008 Arthur Blake *
# * *
# * Licensed under the Apache License, Version 2.0 (the "License"); *
# * you may not use this file except in compliance with the License. *
@@ -25,4 +25,4 @@
# * *
# *************************************************************************************************
java -Xmx1024m -classpath ../build/log4jdbc-1.1alpha1.jar net.sf.log4jdbc.PostLogProfilerProcessor $@
java -Xmx1024m -classpath ../build/log4jdbc3-1.1.jar net.sf.log4jdbc.PostLogProfilerProcessor $@
@@ -1,6 +1,5 @@
/**
*
* Copyright 2007 Arthur Blake
* Copyright 2007-2008 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+2 -2
View File
@@ -1,5 +1,5 @@
/**
* Copyright 2007 Arthur Blake
* Copyright 2007-2008 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,7 +64,7 @@ public class ConnectionSpy implements Connection, Spy
* Create a new ConnectionSpy that wraps a given Connection.
*
* @param realConnection &quot;real&quot; Connection that this ConnectionSpy wraps.
* @param rdbmsSpecifics the RdbmsSpecifics object for formatting logging appropriate for the Rdbms used.
* @param rdbmsSpecifics the RdbmsSpecifics object for formatting logging appropriate for the Rdbms used.
*/
public ConnectionSpy(Connection realConnection, RdbmsSpecifics rdbmsSpecifics)
{
+203 -79
View File
@@ -1,5 +1,5 @@
/**
* Copyright 2007 Arthur Blake
* Copyright 2007-2008 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,15 +30,17 @@ import java.util.Set;
import java.util.TreeSet;
/**
* A JDBC driver which is a facade that delegates to one or more real underlying JDBC drivers.
* The driver will spy on any other JDBC driver that is loaded, simply by prepending <code>jdbc:log4</code>
* to the normal jdbc driver URL used by any other JDBC driver. The driver also loads several well known drivers at
* class load time, so that this driver can be "dropped in" to any java program that uses these drivers
* without making any code changes. The well known driver classes that are loaded are:
* A JDBC driver which is a facade that delegates to one or more real underlying
* JDBC drivers. The driver will spy on any other JDBC driver that is loaded,
* simply by prepending <code>jdbc:log4</code> to the normal jdbc driver URL
* used by any other JDBC driver. The driver also loads several well known
* drivers at class load time, so that this driver can be "dropped in" to any
* java program that uses these drivers without making any code changes.
* The well known driver classes that are loaded are:
* <p/>
* <p/>
* <code>
* <ul>
* <p/>
* <li>oracle.jdbc.driver.OracleDriver</li>
* <li>com.sybase.jdbc2.jdbc.SybDriver</li>
* <li>net.sourceforge.jtds.jdbc.Driver</li>
@@ -47,27 +49,32 @@ import java.util.TreeSet;
* <li>com.informix.jdbc.IfxDriver</li>
* <li>org.apache.derby.jdbc.ClientDriver</li>
* <li>org.apache.derby.jdbc.EmbeddedDriver</li>
* <p/>
* <li>org.hsqldb.jdbcDriver</li>
* <li>org.h2.Driver</li>
* </ul>
* </code>
* <p/>
* <p/>
* Additional drivers can be set via a system property: <b>log4jdbc.drivers</b>
* This can be either a single driver class name or a list of comma separated driver class names.
* This can be either a single driver class name or a list of comma separated
* driver class names.
* <p/>
* If any of the above driver classes cannot be loaded, the driver continues on without failing.
* If any of the above driver classes cannot be loaded, the driver continues on
* without failing.
* <p/>
* Note that the <code>getMajorVersion</code>, <code>getMinorVersion</code> and <code>jdbcCompliant</code>
* method calls attempt to delegate to the last underlying driver requested through any other call that
* accepts a JDBC URL.
* Note that the <code>getMajorVersion</code>, <code>getMinorVersion</code> and
* <code>jdbcCompliant</code> method calls attempt to delegate to the last
* underlying driver requested through any other call that accepts a JDBC URL.
* <p/>
* This can cause unexpected behavior in certain circumstances. For example, if one of these
* 3 methods is called before any underlying driver has been established, then they will return
* default values that might not be correct in all situations. Similarly, if this spy driver
* is used to spy on more than one underlying driver concurrently, the values returned by these
* 3 method calls may change depending on what the last underlying driver used was at the time.
* This will not usually be a problem, since the driver is retrieved by it's URL from the DriverManager
* in the first place (thus establishing an underlying real driver), and in most applications
* their is only one database.
* This can cause unexpected behavior in certain circumstances. For example,
* if one of these 3 methods is called before any underlying driver has been
* established, then they will return default values that might not be correct
* in all situations. Similarly, if this spy driver is used to spy on more than
* one underlying driver concurrently, the values returned by these 3 method
* calls may change depending on what the last underlying driver used was at the
* time. This will not usually be a problem, since the driver is retrieved by
* it's URL from the DriverManager in the first place (thus establishing an
* underlying real driver), and in most applications their is only one database.
*
* @author Arthur Blake
*/
@@ -79,37 +86,137 @@ public class DriverSpy implements Driver
private Driver lastUnderlyingDriverRequested;
/**
* Maps driver class names to RdbmsSpecifics objects for each kind of database.
* Maps driver class names to RdbmsSpecifics objects for each kind of
* database.
*/
private static Map rdbmsSpecifics;
static final SpyLogDelegator log = SpyLogFactory.getSpyLogDelegator();
/**
* Optional package prefix to use for finding application generating point of SQL.
* Optional package prefix to use for finding application generating point of
* SQL.
*/
static final String DebugStackPrefix;
static String DebugStackPrefix;
/**
* Flag to indicate debug trace info should be from app point of view (true if DebugStackPrefix is set.)
* Flag to indicate debug trace info should be from the calling application
* point of view (true if DebugStackPrefix is set.)
*/
static final boolean TraceFromApplication;
static boolean TraceFromApplication;
/**
* Flag to indicate if a warning should be shown if SQL takes more than
* SqlTimingWarnThresholdMsec milliseconds to run. See below.
*/
static boolean SqlTimingWarnThresholdEnabled;
/**
* An amount of time in milliseconds for which SQL that executed taking this
* long or more to run shall cause a warning message to be generated on the
* SQL timing logger.
*
* This threshold will <i>ONLY</i> be used if SqlTimingWarnThresholdEnabled
* is true.
*/
static long SqlTimingWarnThresholdMsec;
/**
* Flag to indicate if an error should be shown if SQL takes more than
* SqlTimingErrorThresholdMsec milliseconds to run. See below.
*/
static boolean SqlTimingErrorThresholdEnabled;
/**
* An amount of time in milliseconds for which SQL that executed taking this
* long or more to run shall cause an error message to be generated on the
* SQL timing logger.
*
* This threshold will <i>ONLY</i> be used if SqlTimingErrorThresholdEnabled
* is true.
*/
static long SqlTimingErrorThresholdMsec;
/**
* Get a Long option from a system property and
* log a debug message about this.
*
* @param propName System property key.
*
* @return the value of that System property key, converted
* to a Long. Or null if not defined or is invalid.
*/
private static Long getLongOption(String propName)
{
String propValue = System.getProperty(propName);
Long longPropValue = null;
if (propValue == null)
{
log.debug("x " + propName + " is not defined");
}
else
{
try
{
longPropValue = new Long(Long.parseLong(propValue));
log.debug(" " + propName + " = " + longPropValue);
}
catch (NumberFormatException n)
{
log.debug("x " + propName + " \"" + propValue +
"\" is not a valid long value");
}
}
return longPropValue;
}
/**
* Get a String option from a system property and
* log a debug message about this.
*
* @param propName System property key.
* @return the value of that System property key.
*/
private static String getStringOption(String propName)
{
String propValue = System.getProperty(propName);
if (propValue == null || propValue.length()==0)
{
log.debug("x " + propName + " is not defined");
propValue = null; // force to null, even if empty String
}
else
{
log.debug(" " + propName + " = " + propValue);
}
return propValue;
}
static
{
log.debug(" log4jdbc initializing...");
log.debug("... log4jdbc initializing ...");
// look for additional driver specified in system properties
DebugStackPrefix = System.getProperty("log4jdbc.debug.stack.prefix");
TraceFromApplication = DebugStackPrefix != null && DebugStackPrefix.length() > 0;
DebugStackPrefix = getStringOption("log4jdbc.debug.stack.prefix");
TraceFromApplication = DebugStackPrefix != null;
if (TraceFromApplication)
Long thresh = getLongOption("log4jdbc.sqltiming.warn.threshold");
SqlTimingWarnThresholdEnabled = (thresh != null);
if (SqlTimingWarnThresholdEnabled)
{
log.debug(" debug entry point prefix is \"" + DebugStackPrefix + "\"");
SqlTimingWarnThresholdMsec = thresh.longValue();
}
// the Set of drivers that this driver spy will preload at instantiation time
// the driver will spy on any driver
thresh = getLongOption("log4jdbc.sqltiming.error.threshold");
SqlTimingErrorThresholdEnabled = (thresh != null);
if (SqlTimingErrorThresholdEnabled)
{
SqlTimingErrorThresholdMsec = thresh.longValue();
}
// The Set of drivers that the log4jdbc driver will preload at instantiation
// time. The driver can spy on any driver type, it's just a little bit
// easier to configure log4jdbc if it's one of these types!
Set subDrivers = new TreeSet();
subDrivers.add("oracle.jdbc.driver.OracleDriver");
@@ -122,17 +229,20 @@ public class DriverSpy implements Driver
subDrivers.add("org.apache.derby.jdbc.EmbeddedDriver");
subDrivers.add("com.mysql.jdbc.Driver");
subDrivers.add("org.postgresql.Driver");
subDrivers.add("org.hsqldb.jdbcDriver");
subDrivers.add("org.h2.Driver");
// look for additional driver specified in system properties
String moreDrivers = System.getProperty("log4jdbc.drivers");
String moreDrivers = getStringOption("log4jdbc.drivers");
if (moreDrivers != null && moreDrivers.length() > 0)
if (moreDrivers != null)
{
String[] moreDriversArr = moreDrivers.split(",");
for (int i = 0; i < moreDriversArr.length; i++)
{
subDrivers.add(moreDriversArr[i]);
log.debug (" will look for additional driver " + moreDriversArr[i]);
}
}
@@ -144,7 +254,8 @@ public class DriverSpy implements Driver
{
// this exception should never be thrown, JDBC just defines it
// for completeness
throw (RuntimeException) new RuntimeException("could not register log4jdbc driver!").initCause(s);
throw (RuntimeException) new RuntimeException
("could not register log4jdbc driver!").initCause(s);
}
// instantiate all the supported drivers and remove
@@ -156,9 +267,9 @@ public class DriverSpy implements Driver
try
{
Class.forName(driverClass);
log.debug("FOUND " + driverClass);
log.debug(" FOUND DRIVER " + driverClass);
}
catch (ClassNotFoundException c)
catch (Throwable c)
{
i.remove();
}
@@ -166,19 +277,22 @@ public class DriverSpy implements Driver
if (subDrivers.size() == 0)
{
log.debug("WARNING! log4jdbc couldn't find any underlying jdbc drivers.");
log.debug("WARNING! " +
"log4jdbc couldn't find any underlying jdbc drivers.");
}
SqlServerRdbmsSpecifics sqlServer = new SqlServerRdbmsSpecifics();
/** create lookup Map for specific rdbms formatters */
rdbmsSpecifics = new HashMap();
rdbmsSpecifics.put("oracle.jdbc.driver.OracleDriver", new OracleRdbmsSpecifics());
rdbmsSpecifics.put("oracle.jdbc.driver.OracleDriver",
new OracleRdbmsSpecifics());
rdbmsSpecifics.put("net.sourceforge.jtds.jdbc.Driver", sqlServer);
rdbmsSpecifics.put("com.microsoft.jdbc.sqlserver.SQLServerDriver", sqlServer);
rdbmsSpecifics.put("com.microsoft.jdbc.sqlserver.SQLServerDriver",
sqlServer);
rdbmsSpecifics.put("weblogic.jdbc.sqlserver.SQLServerDriver", sqlServer);
log.debug(" ... log4jdbc initialized!");
log.debug("... log4jdbc initialized! ...");
}
static RdbmsSpecifics defaultRdbmsSpecifics = new RdbmsSpecifics();
@@ -186,7 +300,7 @@ public class DriverSpy implements Driver
/**
* Get the RdbmsSpecifics object for a given Connection.
*
* @param conn jdbc connection to get RdbmsSpecifics for.
* @param conn JDBC connection to get RdbmsSpecifics for.
* @return RdbmsSpecifics for the given connection.
*/
static RdbmsSpecifics getRdbmsSpecifics(Connection conn)
@@ -224,11 +338,11 @@ public class DriverSpy implements Driver
}
/**
* Get the major version of the driver.
* This call will be delegated to the underlying driver that is being spied upon.
* (if there is no underlying driver found, then 1 will be returned.)
* Get the major version of the driver. This call will be delegated to the
* underlying driver that is being spied upon (if there is no underlying
* driver found, then 1 will be returned.)
*
* @return the major version of the jdbc driver.
* @return the major version of the JDBC driver.
*/
public int getMajorVersion()
{
@@ -243,11 +357,11 @@ public class DriverSpy implements Driver
}
/**
* Get the minor version of the driver.
* This call will be delegated to the underlying driver that is being spied upon.
* (if there is no underlying driver found, then 0 will be returned.)
* Get the minor version of the driver. This call will be delegated to the
* underlying driver that is being spied upon (if there is no underlying
* driver found, then 0 will be returned.)
*
* @return the minor version of the jdbc driver.
* @return the minor version of the JDBC driver.
*/
public int getMinorVersion()
{
@@ -262,25 +376,27 @@ public class DriverSpy implements Driver
}
/**
* Report whether the underlying driver is jdbc compliant.
* If there is no underlying driver, false
* will be returned, because the driver cannot actually do
* any work without an underlying driver.
* Report whether the underlying driver is JDBC compliant. If there is no
* underlying driver, false will be returned, because the driver cannot
* actually do any work without an underlying driver.
*
* @return <code>true</code> if the underlying driver is JDBC Compliant; <code>false</code>
* otherwise.
* @return <code>true</code> if the underlying driver is JDBC Compliant;
* <code>false</code> otherwise.
*/
public boolean jdbcCompliant()
{
return lastUnderlyingDriverRequested != null && lastUnderlyingDriverRequested.jdbcCompliant();
return lastUnderlyingDriverRequested != null &&
lastUnderlyingDriverRequested.jdbcCompliant();
}
/**
* Returns true if this is a <code>jdbc:log4</code> url and if the url is for an underlying driver
* that this DriverSpy can spy on.
* Returns true if this is a <code>jdbc:log4</code> URL and if the URL is for
* an underlying driver that this DriverSpy can spy on.
*
* @param url JDBC URL.
*
* @return true if this Driver can handle the URL.
*
* @param url jdbc url.
* @return true if this Driver can handle the url.
* @throws SQLException if a database access error occurs
*/
public boolean acceptsURL(String url) throws SQLException
@@ -301,9 +417,12 @@ public class DriverSpy implements Driver
* Given a <code>jdbc:log4</code> type URL, find the underlying real driver
* that accepts the URL.
*
* @param url jdbc connection url.
* @return Underlying driver for the given url. Null is returned if the url is not a <code>jdbc:log4</code> type URL
* or there is no underlying driver that accepts the URL.
* @param url JDBC connection URL.
*
* @return Underlying driver for the given URL. Null is returned if the URL is
* not a <code>jdbc:log4</code> type URL or there is no underlying
* driver that accepts the URL.
*
* @throws SQLException if a database access error occurs.
*/
private Driver getUnderlyingDriver(String url) throws SQLException
@@ -330,18 +449,19 @@ public class DriverSpy implements Driver
/**
* Get a Connection to the database from the underlying driver that this
* DriverSpy is spying on.
* <p/>
* If logging is not enabled, an actual Connection to the database returned.
* If logging is enabled, a ConnectionSpy object which wraps the real Connection
* is returned.
* DriverSpy is spying on. If logging is not enabled, an actual Connection to
* the database returned. If logging is enabled, a ConnectionSpy object which
* wraps the real Connection is returned.
*
* @param url jdbc connection url.
* @param url JDBC connection URL
* .
* @param info a list of arbitrary string tag/value pairs as
* connection arguments. Normally at least a "user" and
* "password" property should be included.
* @return a <code>Connection</code> object that represents a
* connection to the URL.
*
* @return a <code>Connection</code> object that represents a
* connection to the URL.
*
* @throws SQLException if a database access error occurs
*/
public Connection connect(String url, Properties info) throws SQLException
@@ -352,7 +472,9 @@ public class DriverSpy implements Driver
return null;
}
url = url.substring(9); // get actual URL that the real driver expects (strip off "jdbc:log4" from url)
// get actual URL that the real driver expects
// (strip off "jdbc:log4" from url)
url = url.substring(9);
lastUnderlyingDriverRequested = d;
Connection c = d.connect(url, info);
@@ -388,14 +510,17 @@ public class DriverSpy implements Driver
* Gets information about the possible properties for the underlying driver.
*
* @param url the URL of the database to which to connect
*
* @param info a proposed list of tag/value pairs that will be sent on
* connect open
* @return an array of <code>DriverPropertyInfo</code> objects describing
* possible properties. This array may be an empty array if
* no properties are required.
* @return an array of <code>DriverPropertyInfo</code> objects describing
* possible properties. This array may be an empty array if no
* properties are required.
*
* @throws SQLException if a database access error occurs
*/
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
throws SQLException
{
Driver d = getUnderlyingDriver(url);
if (d == null)
@@ -406,5 +531,4 @@ public class DriverSpy implements Driver
lastUnderlyingDriverRequested = d;
return d.getPropertyInfo(url, info);
}
}
@@ -1,5 +1,5 @@
/**
* Copyright 2007 Arthur Blake
* Copyright 2007-2008 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/**
* Copyright 2007 Arthur Blake
* Copyright 2007-2008 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ import java.util.Arrays;
* Name of log file is passed in on the command line as the only argument.
*
* Assumptions:
*
*
* 1. Each sql statement in the log is separated by a blank line.
* 2. Each sql statement is terminated with the timing string "{executed in N msec}" where N is the number of
* milliseconds that the sql executed in.
@@ -243,7 +243,7 @@ public class PostLogProfilerProcessor {
* than, equal to, or greater than the specified object.<p>
*
* In this case the comparison is used to sort flagged sql in descending order.
* @param o ProfiledSql Object to compare to this ProfiledSql. Must not be null.
* @param o ProfiledSql Object to compare to this ProfiledSql. Must not be null.
*/
public int compareTo(Object o) {
return ((ProfiledSql)o).execTime.compareTo(execTime);
@@ -1,5 +1,5 @@
/**
* Copyright 2007 Arthur Blake
* Copyright 2007-2008 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/**
* Copyright 2007 Arthur Blake
* Copyright 2007-2008 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,5 +1,5 @@
/**
* Copyright 2007 Arthur Blake
* Copyright 2007-2008 Arthur Blake
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

Some files were not shown because too many files have changed in this diff Show More