This may be useful to somebody. I don't like the blackwater solution very 
much (replacing exec-sql korma function). It's easy to use log4jdbc with 
korma. There is something like this on the web but it is not working with 
the last version of korma.

1) Create/append to the resources/log4j.properties

# the appender used for the JDBC API layer call logging above, sql only
log4j.appender.sql=org.apache.log4j.RollingFileAppender
log4j.appender.sql.File=log/sql.log
log4j.appender.sql.layout=org.apache.log4j.PatternLayout
log4j.appender.sql.layout.ConversionPattern= \u001b[0;31m (SQL)\u001b[m 
%d{yyyy-MM-dd HH:mm:ss.SSS} \u001b[0;32m %m \u001b[m %n

# 
==============================================================================
# JDBC API layer call logging :
# INFO shows logging, DEBUG also shows where in code the jdbc calls were 
made,
# setting DEBUG to true might cause minor slow-down in some environments.
# If you experience too much slowness, use INFO instead.

log4jdbc.drivers=com.mysql.jdbc.Driver

# Log all JDBC calls except for ResultSet calls
log4j.logger.jdbc.audit=FATAL,sql
log4j.additivity.jdbc.audit=false

# Log only JDBC calls to ResultSet objects
log4j.logger.jdbc.resultset=FATAL,sql
log4j.additivity.jdbc.resultset=false

# Log only the SQL that is executed.
log4j.logger.jdbc.sqlonly=FATAL,sql
log4j.additivity.jdbc.sqlonly=false

# Log timing information about the SQL that is executed.
log4j.logger.jdbc.sqltiming=INFO,sql
log4j.additivity.jdbc.sqltiming=false

# Log connection open/close events and connection number dump
log4j.logger.jdbc.connection=FATAL,sql
log4j.additivity.jdbc.connection=false

2) Make sure you have the postgresql (or mysql...) driver on the 
project.clj dependencies:
[org.postgresql/postgresql "9.4-1201-jdbc41"]

3) Add log4jdbc dependency to the project.clj:
[com.googlecode.log4jdbc/log4jdbc "1.2"]

4) Instead using the postgres (or mysql...) function to create the 
connection you have to use:

{:classname   "net.sf.log4jdbc.DriverSpy"
   :subprotocol "log4jdbc"
   :subname     (str "postgresql://" host ":" port "/" dbname)
   :user            user
   :password    password}
 

-- 
You received this message because you are subscribed to the Google Groups 
"Korma" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to