---
title: "Hibernate Log"
author: "choelea"
date: "2015-04-03T20:41:23Z"
tags: []
categories: ["开源软件"]
slug: "hibernate-log"
draft: false
lastmod: "2015-04-03T20:41:23Z"
id: 2199268
url: "https://choelea.iteye.com/blog/2199268"
---

Hibernate cannot log the SQL and its parameters in the same line like you want . The logging provided by the Hibernate (by setting `log4j.logger.org.hibernate.SQL=debug` and `log4j.logger.org.hibernate.type=trace` in the log4j configuration) can only log the SQL and the parameters in the different lines likes this :

```
insert 
intoAddress(address1, address2, city, province) 
values
    (?,?,?,?)
binding parameter [1]as[VARCHAR]- xxxxxx
binding parameter [2]as[VARCHAR]- xxxxxx
binding parameter [3]as[VARCHAR]- xxxx
```

You have to use JDBC proxy driver if you want to log the SQL with the parameters in the same line. I have tried [log4jdbc](http://code.google.com/p/log4jdbc/) and it can do it ,and it also can log the time spent by every SQL statement and log the lines in the code that cause the SQL statements .