• SQL Logging
  • Available logging flags/levels
  • Advanced logging

Architecture Overview

Logging allows you to view, trace, and troubleshoot the runtime behavior of an application. Java Persistence API (JPA) provides a flexible logging system that is integrated with the application server to assist you in troubleshooting problems. 

Best Practices & How To's

Logging Levels

Each of the logging channels use logging levels to control which messages are recorded. The following logging levels are supported by the JPA architecture:

  • TRACE - the most detailed option
  • INFO - information related to the specific channel
  • WARN - warning messages
  • ERROR - error condition messages
  • FATAL - fatal condition messages

Log4j (Required)

  • Log4j logger adaptor has to be configured and used for:
    • logging JPA vendor's actions
    • SQLs and much more, see Hibernate's documentation page for all the available options: Logging
  • JPA Logging is left for the vendors to act upon on
  • Most certified J2EE application servers such as JBoss and Glassfish offer built in logging when used with JPA
    • Tomcat is not a true J2EE server hence it does not offer such functionality out of the box
  • We are requiring logging via Apache Log4j
    • Most JPA Vendors offer logging via various popular frameworks
    • Enforcement: We are requiring the use of Log4j to log JPA in general
      • The pre-defined templates provided include most of basic logging needed
        • See templates and configs section
      •  see Hibernate's documentation page for all the available options: Logging
        • note: setting show_sql=true in the ${data-source}.properties will log SQLs to the standard output -> only use in local environment
          -> for logging SQLs to your applications log file use the template log4j.properties file provided
        • Table 3.9. Hibernate Log Categories

          Category Function
          org.hibernate.SQL Log all SQL DML statements as they are executed
          org.hibernate.type Log all JDBC parameters
          org.hibernate.tool.hbm2ddl Log all SQL DDL statements as they are executed
          org.hibernate.pretty Log the state of all entities (max 20 entities) associated with the session at flush time
          org.hibernate.cache Log all second-level cache activity
          org.hibernate.transaction Log transaction related activity
          org.hibernate.jdbc Log all JDBC resource acquisition
          org.hibernate.hql.ast.AST Log HQL and SQL ASTs during query parsing
          org.hibernate.secure Log all JAAS authorization requests
          org.hibernate Log everything. This is a lot of information but it is useful for troubleshooting

RACFID Logging


Advanced Logging

  • JPA vendors often offer additional extensive logging functinoalities for various purposes
    • see for example
      • Hibernate Envers: SVN for your table; purpose is to keep the history of changes made to a table
      • note: consult with your group before using such functionality


  • Code Review
  • We enforce setting up log4j with the base template (as noted in the templates section) as the most basic form of logging when using JPA


  • Hibernate's documentation page for all the available options: Logging