Guest User

Untitled

a guest
Jan 2nd, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. Full stack traces
  2. =================
  3.  
  4. To enable full stack traces just add the command line argument `-Dgrails.full.stacktrace=true` when calling `grails`, e. g.:
  5.  
  6. grails -Dgrails.full.stacktrace=true run-app
  7.  
  8. SQL logging
  9. ===========
  10.  
  11. First you can enable SQL logging by adding the property `logSql = true` to the data source (in `DataSource.groovy`), e. g.:
  12.  
  13. environments {
  14. development {
  15. dataSource {
  16. url = 'jdbc:mysql://localhost/dbname?autoreconnect=true'
  17. username = 'user'
  18. password = 'secretpwd'
  19. logSql = true
  20. }
  21. }
  22. }
  23.  
  24. This method has the disadvantage that the SQL commands are visible, though, the bound values are not.
  25.  
  26.  
  27. Advanced SQL logging
  28. ====================
  29.  
  30. To produce more output, format the SQL commands, and see the bound parameter values, first turn off the `logSql` property for the database because otherwise it'll output SQL commands twice.
  31.  
  32. Then add the following properties in `DataSource.groovy`:
  33.  
  34. hibernate {
  35. format_sql = true
  36. use_sql_comments = true
  37. }
  38.  
  39. This will produce far more readable SQL commands than simply `logSql` would do. Then, add the following log4j settings to `Config.groovy`:
  40.  
  41. log4j = {
  42. debug 'org.hibernate.SQL'
  43. trace 'org.hibernate.type'
  44. }
  45.  
  46. The first setting logs the SQL commands, the second one logs the bound parameters and the bindings of the result set.
Add Comment
Please, Sign In to add comment