|
|
Hi,
How can I configure Log4J to log SQL statements from groovy.sql.Sql class?
If possible, I'd like to use the same flag used to log Hibernate statements (logSql = true in DataSource.groovy), to turn logging on/off.
Thanks! Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
|
|
Hi Lauro
Jason On Mon, Jan 16, 2012 at 9:42 AM, Lauro Becker <[hidden email]> wrote:
Hi,
How can I configure Log4J to log SQL statements from groovy.sql.Sql class?
If possible, I'd like to use the same flag used to log Hibernate statements (logSql = true in DataSource.groovy), to turn logging on/off.
Thanks! Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
|
|
Hi Jason
Don't you know if is possible log just by adding something like log4j = { debug 'org.hibernate.SQL'} in Config?
Anyway, I'll test p6spy.
Thanks! Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
2012/1/16 Jason Stell <[hidden email]>
Hi Lauro
JasonOn Mon, Jan 16, 2012 at 9:42 AM, Lauro Becker <[hidden email]> wrote:
Hi,
How can I configure Log4J to log SQL statements from groovy.sql.Sql class?
If possible, I'd like to use the same flag used to log Hibernate statements (logSql = true in DataSource.groovy), to turn logging on/off.
Thanks! Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
|
|
I was looking for this once too. I don't think your above suggestion
would work as groovy Sql object doesnt (normally?) use hibernate.
I would be interested in a solution too. Sometimes its nice to see
exactly how values for prepared statements are substituted.
On Mon, Jan 16, 2012 at 8:58 AM, Lauro Becker < [hidden email]> wrote:
> Hi Jason
>
> Don't you know if is possible log just by adding something like log4j =
> { debug 'org.hibernate.SQL'} in Config?
>
> Anyway, I'll test p6spy.
>
> Thanks!
>
> Lauro L. V. Becker
> ---------------------------
> Blog: http://laurobecker.wordpress.com>
>
> 2012/1/16 Jason Stell < [hidden email]>
>>
>> Hi Lauro
>>
>> There's nothing as simple as a config flag for turning on JDBC SQL
>> logging, but you might take a look at the p6spy plugin
>> : http://www.grails.org/p6spy+plugin>>
>>
>> Jason
>>
>>
>> On Mon, Jan 16, 2012 at 9:42 AM, Lauro Becker < [hidden email]>
>> wrote:
>>>
>>> Hi,
>>>
>>> How can I configure Log4J to log SQL statements from groovy.sql.Sql
>>> class?
>>>
>>> If possible, I'd like to use the same flag used to log Hibernate
>>> statements (logSql = true in DataSource.groovy), to turn logging on/off.
>>>
>>> Thanks!
>>>
>>> Lauro L. V. Becker
>>> ---------------------------
>>> Blog: http://laurobecker.wordpress.com>>
>>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
|
|
Indeed. Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
2012/1/16 Jason Davis <[hidden email]>
I was looking for this once too. I don't think your above suggestion
would work as groovy Sql object doesnt (normally?) use hibernate.
I would be interested in a solution too. Sometimes its nice to see
exactly how values for prepared statements are substituted.
On Mon, Jan 16, 2012 at 8:58 AM, Lauro Becker < [hidden email]> wrote:
> Hi Jason
>
> Don't you know if is possible log just by adding something like log4j =
> { debug 'org.hibernate.SQL'} in Config?
>
> Anyway, I'll test p6spy.
>
> Thanks!
>
> Lauro L. V. Becker
> ---------------------------
> Blog: http://laurobecker.wordpress.com
>
>
> 2012/1/16 Jason Stell < [hidden email]>
>>
>> Hi Lauro
>>
>> There's nothing as simple as a config flag for turning on JDBC SQL
>> logging, but you might take a look at the p6spy plugin
>> : http://www.grails.org/p6spy+plugin
>>
>>
>> Jason
>>
>>
>> On Mon, Jan 16, 2012 at 9:42 AM, Lauro Becker < [hidden email]>
>> wrote:
>>>
>>> Hi,
>>>
>>> How can I configure Log4J to log SQL statements from groovy.sql.Sql
>>> class?
>>>
>>> If possible, I'd like to use the same flag used to log Hibernate
>>> statements (logSql = true in DataSource.groovy), to turn logging on/off.
>>>
>>> Thanks!
>>>
>>> Lauro L. V. Becker
>>> ---------------------------
>>> Blog: http://laurobecker.wordpress.com
>>
>>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
|
|
Hi Lauro
It looks like groovy.sql.Sql does do some logging via java.util.logging (not log4j) You could try enabling this by putting something like the following in your Bootstrap.groovy:
... but I haven't tested this. You may also need to tweak your logging.properties file so the ConsoleHandler outputs FINE messages.
Cross-posting this to the groovy ML for better info :) Jason On Mon, Jan 16, 2012 at 9:58 AM, Lauro Becker <[hidden email]> wrote:
Hi Jason
Don't you know if is possible log just by adding something like log4j = { debug 'org.hibernate.SQL'} in Config?
Anyway, I'll test p6spy.
Thanks! 2012/1/16 Jason Stell <[hidden email]>
Hi Lauro
JasonOn Mon, Jan 16, 2012 at 9:42 AM, Lauro Becker <[hidden email]> wrote:
Hi,
How can I configure Log4J to log SQL statements from groovy.sql.Sql class?
If possible, I'd like to use the same flag used to log Hibernate statements (logSql = true in DataSource.groovy), to turn logging on/off.
Thanks! Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
|
|
Wow! It is almost easier using p6spy. :P
I need to write these logs to the same file as log4j does, so I don't know if it helps. I guess I can integrate both with a Handler.
Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
2012/1/16 Jason Stell <[hidden email]>
Hi Lauro
It looks like groovy.sql.Sql does do some logging via java.util.logging (not log4j) You could try enabling this by putting something like the following in your Bootstrap.groovy:
... but I haven't tested this.
You may also need to tweak your logging.properties file so the ConsoleHandler outputs FINE messages.
Cross-posting this to the groovy ML for better info :)
JasonOn Mon, Jan 16, 2012 at 9:58 AM, Lauro Becker <[hidden email]> wrote:
Hi Jason
Don't you know if is possible log just by adding something like log4j = { debug 'org.hibernate.SQL'} in Config?
Anyway, I'll test p6spy.
Thanks! 2012/1/16 Jason Stell <[hidden email]>
Hi Lauro
JasonOn Mon, Jan 16, 2012 at 9:42 AM, Lauro Becker <[hidden email]> wrote:
Hi,
How can I configure Log4J to log SQL statements from groovy.sql.Sql class?
If possible, I'd like to use the same flag used to log Hibernate statements (logSql = true in DataSource.groovy), to turn logging on/off.
Thanks! Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
|
|
Hi Jason,
Following your suggestion about java.util.logging, I've created a very simple solution.
Add the following lines to your Bootstrap, for example:
Logger sqlLogger = Logger.getLogger(Sql.class.getName())
sqlLogger.addHandler(new SqlHandler()); sqlLogger.setLevel(Level.FINE)
Add SqlHandler to your project and update your Config for logging 'groovy.sql'. For example: info 'groovy.sql'.
Cheers, Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
2012/1/16 Lauro Becker <[hidden email]>
Wow! It is almost easier using p6spy. :P
I need to write these logs to the same file as log4j does, so I don't know if it helps. I guess I can integrate both with a Handler.
Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
2012/1/16 Jason Stell <[hidden email]>
Hi Lauro
It looks like groovy.sql.Sql does do some logging via java.util.logging (not log4j) You could try enabling this by putting something like the following in your Bootstrap.groovy:
... but I haven't tested this.
You may also need to tweak your logging.properties file so the ConsoleHandler outputs FINE messages.
Cross-posting this to the groovy ML for better info :)
JasonOn Mon, Jan 16, 2012 at 9:58 AM, Lauro Becker <[hidden email]> wrote:
Hi Jason
Don't you know if is possible log just by adding something like log4j = { debug 'org.hibernate.SQL'} in Config?
Anyway, I'll test p6spy.
Thanks! 2012/1/16 Jason Stell <[hidden email]>
Hi Lauro
JasonOn Mon, Jan 16, 2012 at 9:42 AM, Lauro Becker <[hidden email]> wrote:
Hi,
How can I configure Log4J to log SQL statements from groovy.sql.Sql class?
If possible, I'd like to use the same flag used to log Hibernate statements (logSql = true in DataSource.groovy), to turn logging on/off.
Thanks! Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
|
|
Clever!
Jason On Tue, Jan 17, 2012 at 12:19 PM, Lauro Becker <[hidden email]> wrote:
Hi Jason,
Following your suggestion about java.util.logging, I've created a very simple solution.
Add the following lines to your Bootstrap, for example:
Logger sqlLogger = Logger.getLogger(Sql.class.getName())
sqlLogger.addHandler(new SqlHandler()); sqlLogger.setLevel(Level.FINE)
Add SqlHandler to your project and update your Config for logging 'groovy.sql'. For example: info 'groovy.sql'.
Cheers, Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
2012/1/16 Lauro Becker <[hidden email]>
Wow! It is almost easier using p6spy. :P
I need to write these logs to the same file as log4j does, so I don't know if it helps. I guess I can integrate both with a Handler.
Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
2012/1/16 Jason Stell <[hidden email]>
Hi Lauro
It looks like groovy.sql.Sql does do some logging via java.util.logging (not log4j) You could try enabling this by putting something like the following in your Bootstrap.groovy:
... but I haven't tested this.
You may also need to tweak your logging.properties file so the ConsoleHandler outputs FINE messages.
Cross-posting this to the groovy ML for better info :)
JasonOn Mon, Jan 16, 2012 at 9:58 AM, Lauro Becker <[hidden email]> wrote:
Hi Jason
Don't you know if is possible log just by adding something like log4j = { debug 'org.hibernate.SQL'} in Config?
Anyway, I'll test p6spy.
Thanks! 2012/1/16 Jason Stell <[hidden email]>
Hi Lauro
JasonOn Mon, Jan 16, 2012 at 9:42 AM, Lauro Becker <[hidden email]> wrote:
Hi,
How can I configure Log4J to log SQL statements from groovy.sql.Sql class?
If possible, I'd like to use the same flag used to log Hibernate statements (logSql = true in DataSource.groovy), to turn logging on/off.
Thanks! Lauro L. V. Becker --------------------------- Blog: http://laurobecker.wordpress.com
|
|
Or you could do it this way:
http://stackoverflow.com/questions/2568507/how-to-log-sql-statements-in-grails/2568617#2568617Cheers, Tomislav
2012/1/17 Jason Stell < [hidden email]>:
> Clever!
>
> Jason
>
>
> On Tue, Jan 17, 2012 at 12:19 PM, Lauro Becker < [hidden email]>
> wrote:
>>
>> Hi Jason,
>>
>> Following your suggestion about java.util.logging, I've created a very
>> simple solution.
>>
>> Add the following lines to your Bootstrap, for example:
>>
>>> Logger sqlLogger = Logger.getLogger(Sql.class.getName())
>>> sqlLogger.addHandler(new SqlHandler());
>>> sqlLogger.setLevel(Level.FINE)
>>
>>
>> Add SqlHandler to your project and update your Config for logging
>> 'groovy.sql'. For example: info 'groovy.sql'.
>>
>> Cheers,
>>
>> Lauro L. V. Becker
>> ---------------------------
>> Blog: http://laurobecker.wordpress.com>>
>>
>> 2012/1/16 Lauro Becker < [hidden email]>
>>>
>>> Wow! It is almost easier using p6spy. :P
>>>
>>> I need to write these logs to the same file as log4j does, so I don't
>>> know if it helps. I guess I can integrate both with a Handler.
>>>
>>>
>>> Lauro L. V. Becker
>>> ---------------------------
>>> Blog: http://laurobecker.wordpress.com>>>
>>>
>>> 2012/1/16 Jason Stell < [hidden email]>
>>>>
>>>> Hi Lauro
>>>>
>>>> It looks like groovy.sql.Sql does do some logging via java.util.logging
>>>> (not log4j)
>>>> You could try enabling this by putting something like the following in
>>>> your Bootstrap.groovy:
>>>>
>>>>
>>>> java.util.logging.Logger.getLogger(groovy.sql.Sql.class.getName()).setLevel(java.util.logging.Level.FINE)
>>>>
>>>>
>>>> ... but I haven't tested this.
>>>> You may also need to tweak your logging.properties file so the
>>>> ConsoleHandler outputs FINE messages.
>>>>
>>>> Cross-posting this to the groovy ML for better info :)
>>>>
>>>> Jason
>>>>
>>>>
>>>> On Mon, Jan 16, 2012 at 9:58 AM, Lauro Becker < [hidden email]>
>>>> wrote:
>>>>>
>>>>> Hi Jason
>>>>>
>>>>> Don't you know if is possible log just by adding something like log4j =
>>>>> { debug 'org.hibernate.SQL'} in Config?
>>>>>
>>>>> Anyway, I'll test p6spy.
>>>>>
>>>>> Thanks!
>>>>>
>>>>> Lauro L. V. Becker
>>>>> ---------------------------
>>>>> Blog: http://laurobecker.wordpress.com>>>>>
>>>>>
>>>>> 2012/1/16 Jason Stell < [hidden email]>
>>>>>>
>>>>>> Hi Lauro
>>>>>>
>>>>>> There's nothing as simple as a config flag for turning on JDBC SQL
>>>>>> logging, but you might take a look at the p6spy plugin
>>>>>> : http://www.grails.org/p6spy+plugin>>>>>>
>>>>>>
>>>>>> Jason
>>>>>>
>>>>>>
>>>>>> On Mon, Jan 16, 2012 at 9:42 AM, Lauro Becker < [hidden email]>
>>>>>> wrote:
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> How can I configure Log4J to log SQL statements from groovy.sql.Sql
>>>>>>> class?
>>>>>>>
>>>>>>> If possible, I'd like to use the same flag used to log Hibernate
>>>>>>> statements (logSql = true in DataSource.groovy), to turn logging on/off.
>>>>>>>
>>>>>>> Thanks!
>>>>>>>
>>>>>>> Lauro L. V. Becker
>>>>>>> ---------------------------
>>>>>>> Blog: http://laurobecker.wordpress.com>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
|
|
yeah, that doesnt work with the groovy Sql object.
On Wed, Jan 18, 2012 at 3:15 AM, Tomi N/A < [hidden email]> wrote:
> Or you could do it this way:
>
> http://stackoverflow.com/questions/2568507/how-to-log-sql-statements-in-grails/2568617#2568617>
> Cheers, Tomislav
>
> 2012/1/17 Jason Stell < [hidden email]>:
>> Clever!
>>
>> Jason
>>
>>
>> On Tue, Jan 17, 2012 at 12:19 PM, Lauro Becker < [hidden email]>
>> wrote:
>>>
>>> Hi Jason,
>>>
>>> Following your suggestion about java.util.logging, I've created a very
>>> simple solution.
>>>
>>> Add the following lines to your Bootstrap, for example:
>>>
>>>> Logger sqlLogger = Logger.getLogger(Sql.class.getName())
>>>> sqlLogger.addHandler(new SqlHandler());
>>>> sqlLogger.setLevel(Level.FINE)
>>>
>>>
>>> Add SqlHandler to your project and update your Config for logging
>>> 'groovy.sql'. For example: info 'groovy.sql'.
>>>
>>> Cheers,
>>>
>>> Lauro L. V. Becker
>>> ---------------------------
>>> Blog: http://laurobecker.wordpress.com>>>
>>>
>>> 2012/1/16 Lauro Becker < [hidden email]>
>>>>
>>>> Wow! It is almost easier using p6spy. :P
>>>>
>>>> I need to write these logs to the same file as log4j does, so I don't
>>>> know if it helps. I guess I can integrate both with a Handler.
>>>>
>>>>
>>>> Lauro L. V. Becker
>>>> ---------------------------
>>>> Blog: http://laurobecker.wordpress.com>>>>
>>>>
>>>> 2012/1/16 Jason Stell < [hidden email]>
>>>>>
>>>>> Hi Lauro
>>>>>
>>>>> It looks like groovy.sql.Sql does do some logging via java.util.logging
>>>>> (not log4j)
>>>>> You could try enabling this by putting something like the following in
>>>>> your Bootstrap.groovy:
>>>>>
>>>>>
>>>>> java.util.logging.Logger.getLogger(groovy.sql.Sql.class.getName()).setLevel(java.util.logging.Level.FINE)
>>>>>
>>>>>
>>>>> ... but I haven't tested this.
>>>>> You may also need to tweak your logging.properties file so the
>>>>> ConsoleHandler outputs FINE messages.
>>>>>
>>>>> Cross-posting this to the groovy ML for better info :)
>>>>>
>>>>> Jason
>>>>>
>>>>>
>>>>> On Mon, Jan 16, 2012 at 9:58 AM, Lauro Becker < [hidden email]>
>>>>> wrote:
>>>>>>
>>>>>> Hi Jason
>>>>>>
>>>>>> Don't you know if is possible log just by adding something like log4j =
>>>>>> { debug 'org.hibernate.SQL'} in Config?
>>>>>>
>>>>>> Anyway, I'll test p6spy.
>>>>>>
>>>>>> Thanks!
>>>>>>
>>>>>> Lauro L. V. Becker
>>>>>> ---------------------------
>>>>>> Blog: http://laurobecker.wordpress.com>>>>>>
>>>>>>
>>>>>> 2012/1/16 Jason Stell < [hidden email]>
>>>>>>>
>>>>>>> Hi Lauro
>>>>>>>
>>>>>>> There's nothing as simple as a config flag for turning on JDBC SQL
>>>>>>> logging, but you might take a look at the p6spy plugin
>>>>>>> : http://www.grails.org/p6spy+plugin>>>>>>>
>>>>>>>
>>>>>>> Jason
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Jan 16, 2012 at 9:42 AM, Lauro Becker < [hidden email]>
>>>>>>> wrote:
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> How can I configure Log4J to log SQL statements from groovy.sql.Sql
>>>>>>>> class?
>>>>>>>>
>>>>>>>> If possible, I'd like to use the same flag used to log Hibernate
>>>>>>>> statements (logSql = true in DataSource.groovy), to turn logging on/off.
>>>>>>>>
>>>>>>>> Thanks!
>>>>>>>>
>>>>>>>> Lauro L. V. Becker
>>>>>>>> ---------------------------
>>>>>>>> Blog: http://laurobecker.wordpress.com>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email>
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
|
|