Just added a shiny fresh new donate button to the CompressorRater
I’ve been planning to add new features for quite some time.
If you’d like to help me get motivated, donate!
log4jdbc has been an invaluable tool for me in the Java world for tracing and debugging SQL that my application runs in a development environment.
For a current job, I’ve been coding in ColdFusion (which is built on top of a Java stack), so I’ve added some special features to the latest release of log4jdbc to
make it easier to use in a Coldfusion environment as well.
Here are the basic steps to getting log4jdbc up and running on ColdFusion:
Locate your ColdFusion instance Java classpath folders for the ColdFusion instance(s) that you want to enable log4jdbc for.
On Windows, these folders would typically be in
Where xxx is the name of the ColdFusion instance folder that you’d like to modify (The default is cfusion if you just have a single instance.)
These folders could be in different places depending on the CF version, installation method and platform.
For simplicity, I’ll refer to these two folders as the classes folder and the lib folder in the instructions below:
We are going to be adding several jar and config files to these folders.
Download log4jdbc from http://code.google.com/p/log4jdbc/downloads/list
Any version of log4jdbc should work, but starting with the 1.2 beta 2 release, I’ve added some special features to log4jdbc that make it considerably easier to use in a ColdFusion environment.
If you are running the latest version of ColdFusion (ColdFusion 9 at the time of this writing) then you are on a Java 6 platform, so you should use the JDBC 4 version of log4jdbc.
Earlier versions of ColdFusion based on JDK 4 or 5 will need the JDBC 3 version.
Place the jar file for log4jdbc into the lib folder.
For my setup, I decided to use logback for the logging system. You could also use log4j or any of the other slf4j supported logging systems if you want, but these instructions assume logback.
Download the latest version of slf4j and any other additional jar files for your logging system and place the appropriate jar files into the lib folder.
In my case, for using logback, I placed slf4j-api-1.6.0.jar, logback-core-0.9.21.jar and logback-classic-0.9.21.jar into the lib folder.
Next, I configured log4jdbc and logback:
Both libraries will look in the classpath for configuration files, so first I created log4jdbc.properties in the classes folder:
! ! see http://code.google.com/p/log4jdbc/ ! log4jdbc.auto.load.popular.drivers=false log4jdbc.dump.sql.maxlinelength=0 ! suppress annoying exception that CF produces constantly log4jdbc.suppress.generated.keys.exception=true
This is one of the features in log4jdbc that was added for ColdFusion- that is, the ability to configure it from a properties file rather than system properties.
It is not readily obvious how to change system properties for the JVM in CF (although it’s certainly possible.) Besides, this way of configuring log4jdbc is much more convenient, even in the Java world.
The last option in the properties file is another option I added for ColdFusion: Setting log4jdbc.suppress.generated.keys.exception to true suppresses an annoying exception that ColdFusion otherwise constantly generates silently, thus clogging up the log files with useless information.
I also turn off the auto loading of popular drivers which isn’t necessary because Coldfusion will already load those for you.
Next I created a logback.xml file in the classes folder to configure logback:
<?xml version="1.0" encoding="UTF-8" ?> <!-- An example log4j configuration xml file for logback --> <!-- Logging levels are: --> <!-- TRACE, DEBUG, INFO, WARN, ERROR, ALL or OFF --> <!-- See http://logback.qos.ch/manual/ for logback manual --> <!-- scan for changes to this configuration file, once a minute --> <configuration scan="true" scanPeriod="10 seconds"> <appender name="sql"> <file>/logs/log.sql</file> <append>false</append> <encoder> <!-- See http://logback.qos.ch/manual/layouts.html#ClassicPatternLayout --> <pattern>%n-------- %date --------%n%msg%n</pattern> </encoder> </appender> <!-- log4jdbc sql & jdbc logging --> <logger name="jdbc.sqlonly" additivity="false"> <level value="INFO" /> <appender-ref ref="sql" /> </logger> <logger name="jdbc.sqltiming" additivity="false"> <level value="OFF" /> </logger> <logger name="jdbc.audit" additivity="false"> <level value="OFF" /> </logger> <logger name="jdbc.resultset" additivity="false"> <level value="OFF" /> </logger> <logger name="jdbc.connection" additivity="false"> <level value="OFF" /> </logger> <logger name="log4jdbc.debug" additivity="false"> <level value="DEBUG" /> <appender-ref ref="sql" /> </logger> <root level="debug"> <appender-ref ref="sql" /> </root> </configuration>
This is a simple logging configuration file that just logs the SQL that is produced to a single log file named log.sql in the C:\logs folder (make sure to create the C:\logs folder too!)
Additionally, the log4jdbc.debug log is turned on to the same log file so I can see the log4jdbc startup preamble log messages.
Next you need to modify the datasources for which you want to log the SQL:
Go to the datasources section in the ColdFusion administrator for the instance(s) you are changing. In my case, I kept the original datasource around and then created a new datasource with _log4jdbc appended to the name.
Then in my CF code, I changed the datasource I was referencing. This was so I could easily switch between the two.
CF doesn’t readily expose the actual internal JDBC driver that it uses for common database types, so I had to figure that out via some sleuthing.
You have to set up your datasource as a type “other” so that you can directly specify that your JDBC driver is a log4jdbc driver.
So in my case, I am using SQL Server, so I figured out (through looking inside some jar files and other trial and error) that the JDBC URL equivalent for my datasource. I created a data source of type ‘other’ and specified a URL like:
You can also load and use a directly specified, fully qualified class name for a JDBC driver from a vendor (for example, just use the Microsoft or JTDS driver on SQL Server), but I’ve found that there are some quirks in the way it handles some issues that may require you to change some code to get things working properly (not an option on the huge code base I am working with.)
Note that the jdbc:log4 part at the beginning of the JDBC URL is what makes the magic happen so that log4jdbc wraps the driver.
The URL will be different for other database types of course, and I haven’t had the need to figure out the correct URL for those types yet, so you might have to do some sleuthing to figure that out…
Set the Driver Class to net.sf.log4jdbc.DriverSpy, fill in the username and password as required by your database and you can leave the rest of the datasource settings blank.
Once this is done, restart your CF instance service so that the new jars and classpath changes will be recognized, and you should be ready to go.
SQL will be logged to the C:\logs\log.sql file.
On windows, the tail command from cygwin is particularly useful to monitor the log from a command prompt e.g. tail -f c:\logs\log.sql
I named my log file with a .sql extension on purpose so that I get syntax highlighting of the SQL in my favorite text editor for free.
You can and should of course customize this setup to your hearts content.
Read the log4jdbc manual at http://code.google.com/p/log4jdbc/ for more information on all the options and possibilities.
Good luck and I hope this works for you and helps you out as much as it has for me!
I’ve been working on this little database browser in my spare time for almost 3 years now…
The idea is to have a light-weight interface where you can quickly search for and query data without having to use SQL for most things. Because it’s a web app (unlike most tools in this category), you can use it to access databases remotely without installing any client software.
It can also be embedded into another web app to provide simple administrator functionality for those times where you just have to drop into the database to fix a problem or to run some quick reports or view some data. You can impose additional access rights to the database (such as which tables are visible, simple CRUD flags, etc.) to expose a smaller view of the database as well.
I’ve been excited about this project for a long time, but always hampered by not having enough time to work on it. I don’t have a publicly available download yet, but hopefully that will be coming soon. Check out the basic features and screencasts at http://dbframe.com
Should have done this a long time ago… Instead of running the Packer compressor in the CompressorRater with Java SE 6 Scripting (aka Rhino), I’m now using SpiderMonkey… the result is a 20X speed boost for Packer! Try it yourself!
For today’s 1.0.7 release, I also put back online the YUI (now updated to 3.0.0beta1) & ExtJS libs, and re-generated all the test results for common JS libs with Packer running native Spidermonkey.
It’s been over a year since the last update and this update is way past due!
This is just a minor release– I’ve updated the YUI compressor to the latest version (version 2.4.2 at the time of this writing) and updated the popular library examples:
and took the popular library examples offline for now:
I’ve got lots of great ideas for CompressorRater if I can find the time to work on it…
I heard a really fascinating story on NPR today. New research in the journal of neuroscience found that basically, the faster the nerve impulses can travel down the pathways in your brain, the higher your IQ is.
The article really piqued my interest as I’ve often wished I could get more things done and be more productive and pondered how I could work smarter or even be smarter on a more permanent basis… what are the limiting factors of my productivity and what are the limiting factors of my brain… ?
I find this fascinating…
My questions are:
How can we use this knowledge to increase our intelligence?
What other significant factors are there that contribute to intelligence?
Are faster processing and intelligence, in fact the same thing?
If we make the analogy with computers, a faster computer is obviously more desirable than a slow one because with faster hardware, we can run more complex rich software programs that do more things for us, and we can multitask more programs at once as well.
Indeed, faster chip speeds at a lower unit of cost (along with higher storage capacity) have been the single most important goals in chip manufacturing and computer advancement for as long as I can remember…
Logically it seems like faster processing is not equivalent to more intelligence, because a really dumb person wouldn’t come up with the same solutions as a really intelligent person, no matter how much time you gave them; or would they? Would a room full of 10 really slow people come up with an equally brilliant solution to a problem as one really smart person with 10x the intelligence?
Notice I said slow people above instead of dumb people… It seems that at some level this notion of slowness and low intelligence is actually obvious common knowledge, as the terms, “slow” and “dumb” are more or less interchangeable.
If we could somehow increase the speed of transmission of the brain signals of slow individuals, could we make them into more intelligent people?
A lot to think about for sure…
UPDATE: another article about it!
It’s been a little while since the last release of jabsorb…
This one is a fairly minor release, yet nevertheless important.
You can download the release here:
And for general user discussion on the jabsorb library, go here:
The next alpha release for log4jdbc is out! Get it while it’s hot….
1. Fixed a bug with batched SQL in this release (thanks to Daniel Doubleday for reporting this)
2. Added simple getter methods for all the underlying wrapped objects.
For example, you can get the real Connection from the ConnectionSpy like this:
Connection realConnection = ((ConnectionSpy) conn).getRealConnection();
or you can get the real Statement from the StatementSpy like this:
Statement realStmt = ((StatementSpy) stmt).getRealStatement();
The simple getter methods added to log4jdbc were also added to the JDBC 4 version for consistency but please keep in mind that if you are lucky enough to be using JDBC 4, it’s best to use the more powerful Wrapper interface (which has always been fully supported in the JDBC 4 version of log4jdbc.)
I’ve been meaning to add this feature for awhile, but was prompted again by this issue raised by jrobertray.
3. Finally, I’ve added a new option for turning off SQL Statement warnings. log4jdbc has always included warnings in the logs when simple Statements were used to execute SQL. This is because a database can usually pre-compile and cache PreparedStatements much more efficiently (especially when running many many similar SQL statements with only differing bind variables.) Also, using Statements can sometimes have security implications if used improperly (binding variables is much cleaner than concatenating strings together to form your SQL!) I’ve realized that this warning might annoy some people (aka me!), so I’ve turned it off by default. You can turn it back on by setting the log4jdbc.statement.warn system property to true.
I hope you enjoy this release, and as always, please send me feedback!
I’m getting email about log4jdbc on a daily basis now. I’ve created a new google group for questions, feedback and general support. From now on, please send your general questions, feedback, feature request etc. to this new group.
Here are the essentials:
I’m also in the process of moving the project hosting to google code (It’s just so much easier than SourceForge!) There isn’t much there yet, but it will be expanding soon: