I've got web application using Spring
. To connect with my database I'm using Hibernate
. I've got requirement to log all SQL queries executed by application users (something like database logs per application user). What I am doing now is very bad - I am parsing log4j logs and puts them into database with application user as author. I was wondering if is there any possibility to achieve this by database logging-system? The problem is that I am connecting to ma database via Hibernate
with single user with name postgres - so is it possible to make some magic and tell (via Hibernate/Spring/whatever) database logging-system that this SQL is executing user with login XXX (not user with login postgres)? There is no need, to browse this logs via web application - it is good enough to use database logging-system and browse it with native tools (like pgAdmin
).
Any ideas?
Thanks, Arek