Is there a preferred way of logging sql statements?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Is there a preferred way of logging sql statements?

marcopas
i want to log sql generated by an application and have started to read
about sql logging in a Grails application.

I tried to set the logSql = true setting but this gives me an
unreadable set of sql and parameters. (a lot of parameters that are
difficult to map to the sql statement)

Is there a prefered way of logging the sql so one can track the sql
and look for performance bottlenecks? Should is use log4jdbc for
example?

All hints and tips are welcome!

/Marco

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Is there a preferred way of logging sql statements?

sergiomichels
Normally I use logSql and format_sql (this is in the hibernate block).

Also, set to trace the log level of hibernate and you will see the values used in the query.


trace 'org.hibernate.type'



--
Sérgio Michels


On Fri, Jan 18, 2013 at 5:44 PM, Marco Pas <[hidden email]> wrote:
i want to log sql generated by an application and have started to read
about sql logging in a Grails application.

I tried to set the logSql = true setting but this gives me an
unreadable set of sql and parameters. (a lot of parameters that are
difficult to map to the sql statement)

Is there a prefered way of logging the sql so one can track the sql
and look for performance bottlenecks? Should is use log4jdbc for
example?

All hints and tips are welcome!

/Marco

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Is there a preferred way of logging sql statements?

Konstantinos Kostarellis
In reply to this post by marcopas


2013/1/18 Marco Pas <[hidden email]>
i want to log sql generated by an application and have started to read
about sql logging in a Grails application.

I tried to set the logSql = true setting but this gives me an
unreadable set of sql and parameters. (a lot of parameters that are
difficult to map to the sql statement)

Is there a prefered way of logging the sql so one can track the sql
and look for performance bottlenecks? Should is use log4jdbc for
example?

All hints and tips are welcome!

/Marco

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Is there a preferred way of logging sql statements?

marcopas
In reply to this post by sergiomichels
Is have the following settings in my Config.. And with this i am
getting the sql but without the parameters. Is there a way of getting
the parameters or am i doing something wrong?

dataSource {
.....
    logSql = true
}

hibernate {
    format_sql = true
    use_sql_comments = true
}

This is exampleoutput i get in the console
/* criteria query */ select
        this_.id as id24_0_,
        this_.version as version24_0_,
        this_.account_expired as account3_24_0_,
        this_.account_locked as account4_24_0_,
        this_.date_created as date5_24_0_,
        this_.enabled as enabled24_0_,
        this_.last_login as last7_24_0_,
        this_.last_updated as last8_24_0_,
        this_.`password` as password9_24_0_,
        this_.password_expired as password10_24_0_,
        this_.username as username24_0_,
        this_.who_created as who12_24_0_,
        this_.who_updated as who13_24_0_,
        this_.class as class24_0_
    from
        user this_
    where
        this_.username=? limit ?

2013/1/18 Sergio Michels <[hidden email]>:

> Normally I use logSql and format_sql (this is in the hibernate block).
>
> Also, set to trace the log level of hibernate and you will see the values
> used in the query.
>
>
> trace 'org.hibernate.type'
>
>
>
>
> --
> Sérgio Michels
>
>
> On Fri, Jan 18, 2013 at 5:44 PM, Marco Pas <[hidden email]> wrote:
>>
>> i want to log sql generated by an application and have started to read
>> about sql logging in a Grails application.
>>
>> I tried to set the logSql = true setting but this gives me an
>> unreadable set of sql and parameters. (a lot of parameters that are
>> difficult to map to the sql statement)
>>
>> Is there a prefered way of logging the sql so one can track the sql
>> and look for performance bottlenecks? Should is use log4jdbc for
>> example?
>>
>> All hints and tips are welcome!
>>
>> /Marco
>>
>> ---------------------------------------------------------------------
>> 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


Reply | Threaded
Open this post in threaded view
|

Re: Is there a preferred way of logging sql statements?

marcopas
In reply to this post by Konstantinos Kostarellis
Thanks for the pointers!!! To make things clear for me, the parameters
inside the queries still have to be replaced visually. So the output
will still be as i mentioned and the parameters will be below the sql
statement. Or is there still a way of getting the parameters inside
the query?

2013/1/18 Konstantinos Kostarellis <[hidden email]>:

> http://burtbeckwith.com/blog/?p=1604
> http://burtbeckwith.com/blog/?p=1654
>
> :)
>
>
> 2013/1/18 Marco Pas <[hidden email]>
>>
>> i want to log sql generated by an application and have started to read
>> about sql logging in a Grails application.
>>
>> I tried to set the logSql = true setting but this gives me an
>> unreadable set of sql and parameters. (a lot of parameters that are
>> difficult to map to the sql statement)
>>
>> Is there a prefered way of logging the sql so one can track the sql
>> and look for performance bottlenecks? Should is use log4jdbc for
>> example?
>>
>> All hints and tips are welcome!
>>
>> /Marco
>>
>> ---------------------------------------------------------------------
>> 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