Getting instance of Hibernate's Logger?

I have cross-posted this question in the CommandBox/Railo groups since I’m
not sure exactly where it lands.

I am trying to get the Logger instance that Hibernate uses so I can add
additional appenders to it. In ACF, this is pretty straight-forward:
createObject(“java”, “org.apache.log4j.Logger”).getLogger(
“org.hibernate.SQL”);

The instance of Railo in CommandBox doesn’t appear to have this Logger
available. I looked at the* log4j.properties* file which consists of the
following:

###--------------- Hibernate Log Settings ------

Set Hibernate log

log4j.logger.org.hibernate=ERROR, HIBERNATECONSOLE

log just the SQL

#log4j.logger.org.hibernate.SQL=DEBUG, HIBERNATECONSOLE
#log4j.additivity.org.hibernate.SQL=false

Also log the parameter binding to the prepared statements.

#log4j.logger.org.hibernate.type=DEBUG

log schema export/update

log4j.logger.org.hibernate.tool.hbm2ddl=DEBUG, HIBERNATECONSOLE

log cache activity

log4j.logger.org.hibernate.cache=ERROR, HIBERNATECONSOLE

HibernateConsole is set to be a ColsoleAppender for Hibernate message

using a PatternLayout.
log4j.appender.HIBERNATECONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.HIBERNATECONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.HIBERNATECONSOLE.layout.ConversionPattern=%d{MM/dd HH:mm:ss}
[%t] HIBERNATE %-5p - %m%n%n#—

org.hibernate appears to be the name of the Logger used for the
HIBERNATECONSOLE appender. However, when iterating over the available
Loggers, I don’t see it listed:

createObject(“java”, “org.apache.log4j.LogManager”).getLoggerRepository().
getCurrentLoggers();

// result
server.scope
server.deploy
server.thread
web.2e59f4276de7358dd391f1b2c6fcc59f.requesttimeout
server.mapping
server.search
server.gateway
web.2e59f4276de7358dd391f1b2c6fcc59f.trace
server.remoteclient
server.memory
web.2e59f4276de7358dd391f1b2c6fcc59f.application
web.2e59f4276de7358dd391f1b2c6fcc59f.gateway
web.2e59f4276de7358dd391f1b2c6fcc59f.scheduler
web.2e59f4276de7358dd391f1b2c6fcc59f.mail
web.2e59f4276de7358dd391f1b2c6fcc59f.scope
org.apache.axis.enterprise

  • CONSOLE
    web.2e59f4276de7358dd391f1b2c6fcc59f.remoteclient
    server.orm
    web.2e59f4276de7358dd391f1b2c6fcc59f.exception
    web.2e59f4276de7358dd391f1b2c6fcc59f.orm
    server.rest

These appear to be the Loggers referenced under the
/engine/railo/railo-server/ and /engine/railo/railo-web/ directories.
None of the attached appenders appear to affect the system.out.txt file
in /server/{serverhash-name}/log/.

Any thoughts on obtaining the org.hibernate Logger?

This has been solved. I’m not sure how Railo/Lucee handle adding loggers
(perhaps at runtime?), but loading the Configurator prior to getting the
Loggers included the Hibernate loggers:

propPath = “C:\Users\tlee04.CommandBox\lib\log4j.properties”;
configurator = createObject(“java”,
“org.apache.log4j.PropertyConfigurator”);
configurator.configure(propPath);

loggers = createObject(“java”,
“org.apache.log4j.LogManager”).getCurrentLoggers();

while(loggers.hasMoreElements()) {
logger = loggers.nextElement();
parent = logger.getParent();
appenders = logger.getAllAppenders();
writeoutput("#logger.getName()# (#parent.getName()#)
");

while (appenders.hasMoreElements()) {
appender = appenders.nextElement();
if (len(appender.getName()) > 0) {
writeoutput("   - #appender.getName()# -
#appender.getTarget()#
");
}
}
}

/*
server.scope (root)
server.deploy (root)
server.thread (root)
org.hibernate (root)

  • HIBERNATECONSOLE - System.out
    web.2e59f4276de7358dd391f1b2c6fcc59f.requesttimeout (root)
    server.mapping (root)
    server.search (root)
    org.hibernate.cache (org.hibernate)
  • HIBERNATECONSOLE - System.out
    server.gateway (root)
    web.2e59f4276de7358dd391f1b2c6fcc59f.trace (root)
    server.remoteclient (root)
    server.memory (root)
    web.2e59f4276de7358dd391f1b2c6fcc59f.application (root)
    web.2e59f4276de7358dd391f1b2c6fcc59f.gateway (root)
    web.2e59f4276de7358dd391f1b2c6fcc59f.scheduler (root)
    web.2e59f4276de7358dd391f1b2c6fcc59f.mail (root)
    web.2e59f4276de7358dd391f1b2c6fcc59f.scope (root)
    org.apache.axis.enterprise (root)
  • CONSOLE - System.out
    web.2e59f4276de7358dd391f1b2c6fcc59f.remoteclient (root)
    server.orm (root)
    web.2e59f4276de7358dd391f1b2c6fcc59f.exception (root)
    org.hibernate.tool.hbm2ddl (org.hibernate)
  • HIBERNATECONSOLE - System.out
    web.2e59f4276de7358dd391f1b2c6fcc59f.orm (root)
    server.rest (root)
    */On Friday, March 20, 2015 at 3:49:26 PM UTC-4, Tristan Lee wrote:

I have cross-posted this question in the CommandBox/Railo groups since I’m
not sure exactly where it lands.

I am trying to get the Logger instance that Hibernate uses so I can add
additional appenders to it. In ACF, this is pretty straight-forward:
createObject(“java”, “org.apache.log4j.Logger”).getLogger(
“org.hibernate.SQL”);

The instance of Railo in CommandBox doesn’t appear to have this Logger
available. I looked at the* log4j.properties* file which consists of the
following:

###--------------- Hibernate Log Settings ------

Set Hibernate log

log4j.logger.org.hibernate=ERROR, HIBERNATECONSOLE

log just the SQL

#log4j.logger.org.hibernate.SQL=DEBUG, HIBERNATECONSOLE
#log4j.additivity.org.hibernate.SQL=false

Also log the parameter binding to the prepared statements.

#log4j.logger.org.hibernate.type=DEBUG

log schema export/update

log4j.logger.org.hibernate.tool.hbm2ddl=DEBUG, HIBERNATECONSOLE

log cache activity

log4j.logger.org.hibernate.cache=ERROR, HIBERNATECONSOLE

HibernateConsole is set to be a ColsoleAppender for Hibernate message

using a PatternLayout.
log4j.appender.HIBERNATECONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.HIBERNATECONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.HIBERNATECONSOLE.layout.ConversionPattern=%d{MM/dd HH:mm:ss
} [%t] HIBERNATE %-5p - %m%n%n
#—

org.hibernate appears to be the name of the Logger used for the
HIBERNATECONSOLE appender. However, when iterating over the available
Loggers, I don’t see it listed:

createObject(“java”, “org.apache.log4j.LogManager”).getLoggerRepository().
getCurrentLoggers();

// result
server.scope
server.deploy
server.thread
web.2e59f4276de7358dd391f1b2c6fcc59f.requesttimeout
server.mapping
server.search
server.gateway
web.2e59f4276de7358dd391f1b2c6fcc59f.trace
server.remoteclient
server.memory
web.2e59f4276de7358dd391f1b2c6fcc59f.application
web.2e59f4276de7358dd391f1b2c6fcc59f.gateway
web.2e59f4276de7358dd391f1b2c6fcc59f.scheduler
web.2e59f4276de7358dd391f1b2c6fcc59f.mail
web.2e59f4276de7358dd391f1b2c6fcc59f.scope
org.apache.axis.enterprise

  • CONSOLE
    web.2e59f4276de7358dd391f1b2c6fcc59f.remoteclient
    server.orm
    web.2e59f4276de7358dd391f1b2c6fcc59f.exception
    web.2e59f4276de7358dd391f1b2c6fcc59f.orm
    server.rest

These appear to be the Loggers referenced under the
/engine/railo/railo-server/ and /engine/railo/railo-web/ directories.
None of the attached appenders appear to affect the system.out.txt file
in /server/{serverhash-name}/log/.

Any thoughts on obtaining the org.hibernate Logger?