Ortus ORM Extension
  • Introduction
    • Release History
      • What's New With 6.x
      • What's New With 5.x
    • About This Book
  • Getting Started
    • Installation
    • Configuration
      • Custom Hibernate Config
      • Secondary Caches
      • Logging
  • Modeling
    • Entities
    • Identifiers
    • Properties
    • Relationships
  • Usage
    • Built-In Functions
    • Querying
    • Events
    • Session Management
    • HQL
    • Transactions
    • Caching
  • External Links
    • API Docs for v6.5.2
    • Source Code
    • Issue Tracker
Powered by GitBook
On this page
  • How can I configure/acquire Hibernate logging in the Ortus ORM Extension?
  • How can I configure/acquire Hibernate logging in the Lucee Hibernate Extension?
  • Lucee versions running Log4J 1.x
  • Lucee versions running Log4J 2.x

Was this helpful?

Edit on GitHub
Export as PDF
  1. Getting Started
  2. Configuration

Logging

How do Hibernate logs work in the Ortus ORM Extension?

How can I configure/acquire Hibernate logging in the Ortus ORM Extension?

The Ortus ORM Extension reconfigures all Hibernate logging output on startup to log ERROR-level events to the server console.

How can I configure/acquire Hibernate logging in the Lucee Hibernate Extension?

This depends on the version of Lucee you are running - specifically, on whether you're on Log4J 2 or not.

Lucee versions running Log4J 1.x

Lucee versions containing the older log4j 1.x can use this code to set a custom logging level and redirect the Hibernate logs to the server console:

void function setupHibernateLogging( level = "WARN" ){
	var Logger       = createObject( "java", "org.apache.log4j.Logger" );
	var log4jLevel   = createObject( "java", "org.apache.log4j.Level" );
	var hibernateLog = Logger.getLogger( "org.hibernate" );
	// set a custom log level
	hibernateLog.setLevel( log4jLevel[ arguments.level ] );

	/**
	 * Redirect all Hibernate logs to system.out
	 */
	if ( listFindNoCase( "Lucee", server.coldfusion.productname ) ) {
		var printWriter     = getPageContext().getConfig().getOutWriter();
		var layout          = createObject( "java", "lucee.commons.io.log.log4j.layout.ClassicLayout" );
		var consoleAppender = createObject( "java", "lucee.commons.io.log.log4j.appender.ConsoleAppender" ).init(
			printWriter,
			layout
		);
		hibernateLog.addAppender( consoleAppender );
		writeDump( var = "** Lucee Hibernate Logging Redirected", output = "console" );
	}
}

Lucee versions running Log4J 2.x

PreviousSecondary CachesNextEntities

Last updated 1 year ago

Was this helpful?

For versions of Lucee running log4j 2.x, the above workaround does not apply. If you are interested in tweaking the Hibernate logging level in the Lucee Hibernate extension, I would suggest and future users can benefit from the shared knowledge.

sponsoring this feature