Question

I am trying to log the SQL produced by Squeryl in a Play 2 application, for debugging purposes. I am using this with the following Oracle logging properties:

.level=SEVERE
oracle.jdbc.level=FINE
oracle.jdbc.handlers=java.util.logging.ConsoleHandler
java.util.logging.ConsoleHandler.level=ALL
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
oracle.net.ns.level=FINEST
oracle.net.ns.handlers=java.util.logging.ConsoleHandler

This has worked for me before in a non-Play application with the same Oracle driver jar, but in a Play application, the JUL-to-SLF4J bridge seems to be causing a problem:

Oops, cannot start the server.
Configuration error: Configuration error[Cannot connect to database [default]]
    at play.api.Configuration$.play$api$Configuration$$configError(Configuration.scala:92)
    at play.api.Configuration.reportError(Configuration.scala:570)
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:252)
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:243)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
    at scala.collection.AbstractTraversable.map(Traversable.scala:105)
    at play.api.db.BoneCPPlugin.onStart(DB.scala:243)
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:88)
    at play.api.Play$$anonfun$start$1$$anonfun$apply$mcV$sp$1.apply(Play.scala:88)
    at scala.collection.immutable.List.foreach(List.scala:318)
    at play.api.Play$$anonfun$start$1.apply$mcV$sp(Play.scala:88)
    at play.api.Play$$anonfun$start$1.apply(Play.scala:88)
    at play.api.Play$$anonfun$start$1.apply(Play.scala:88)
    at play.utils.Threads$.withContextClassLoader(Threads.scala:18)
    at play.api.Play$.start(Play.scala:87)
    at play.core.StaticApplication.<init>(ApplicationProvider.scala:52)
    at play.core.server.NettyServer$.createServer(NettyServer.scala:243)
    at play.core.server.NettyServer$$anonfun$main$3.apply(NettyServer.scala:279)
    at play.core.server.NettyServer$$anonfun$main$3.apply(NettyServer.scala:274)
    at scala.Option.map(Option.scala:145)
    at play.core.server.NettyServer$.main(NettyServer.scala:274)
    at play.core.server.NettyServer.main(NettyServer.scala)
Caused by: java.lang.IllegalArgumentException: can't parse argument number 18=false
    at java.text.MessageFormat.makeFormat(MessageFormat.java:1339)
    at java.text.MessageFormat.applyPattern(MessageFormat.java:458)
    at java.text.MessageFormat.<init>(MessageFormat.java:350)
    at java.text.MessageFormat.format(MessageFormat.java:811)
    at org.slf4j.bridge.SLF4JBridgeHandler.getMessageI18N(SLF4JBridgeHandler.java:268)
    at org.slf4j.bridge.SLF4JBridgeHandler.callLocationAwareLogger(SLF4JBridgeHandler.java:223)
    at org.slf4j.bridge.SLF4JBridgeHandler.publish(SLF4JBridgeHandler.java:301)
    at java.util.logging.Logger.log(Logger.java:481)
    at java.util.logging.Logger.doLog(Logger.java:503)
    at java.util.logging.Logger.log(Logger.java:547)
    at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:919)
    at oracle.net.ns.NSProtocol.connect(NSProtocol.java:267)
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1625)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:365)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:557)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:233)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:29)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:556)
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:185)
    at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:351)
    at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416)
    at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:120)
    at play.api.db.BoneCPPlugin$$anonfun$onStart$1.apply(DB.scala:245)
    ... 22 more

I tried simply removing the JUL to SLF4J bridge jar from my deployed application, but Play refuses to start if that jar isn't present, so that didn't work.

I obviously don't need to use this particular approach, I just want some way to log the SQL selects being executed (preferably without admin access to the Oracle server).

Was it helpful?

Solution

I just needed to change the oracle.net.ns.level to SEVERE. Logging of oracle.net is only needed if you want to log the network packets being sent to and from the server, which I didn't need in this case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top