Skip to content

HHH-19611 demote many DEBUG-level log messages to TRACE #10525

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Jul 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
74f8976
demote many DEBUG-level log messages to TRACE
gavinking Jul 12, 2025
055b4fe
improvements to TRACE-level logging
gavinking Jul 13, 2025
8ba81d4
change how HQL functions are logged at startup
gavinking Jul 13, 2025
a311903
avoid use of deprecated service lookup
gavinking Jul 13, 2025
7495085
downgrade two more DEBUG-level messages to TRACE
gavinking Jul 13, 2025
d5ec2f6
very minor code cleanups in ResourceRegistryStandardImpl
gavinking Jul 13, 2025
6b9a6d3
very minor code cleanups in ManagedTypeProcessor
gavinking Jul 13, 2025
0e14088
introduce ResourceRegistryLogger
gavinking Jul 13, 2025
e3a06c6
move logging in JdbcCoordinatorImpl and LogicalConnectionManagedImpl …
gavinking Jul 13, 2025
5113f19
massive cleanup of NaturalIdResolutionsImpl
gavinking Jul 13, 2025
7d2fc89
move NaturalIdLogging to package with its only client
gavinking Jul 13, 2025
e3d89dd
improve logging for Services and Statistics
gavinking Jul 13, 2025
60a413c
trivial changes to logging in JndiServiceImpl
gavinking Jul 13, 2025
142b9c6
move logging to JdbcEnvironmentInitiator to JdbcLogging
gavinking Jul 13, 2025
13215a5
fix verbosity of logging in BootstrapContextImpl and ClassLoaderAcces…
gavinking Jul 13, 2025
6c7d383
improve log message in StrategySelectorImpl
gavinking Jul 13, 2025
639a7b9
slightly improve format of log message in AttributeFactory
gavinking Jul 13, 2025
4133366
more consistent format for logging in boot.model package
gavinking Jul 13, 2025
a70ea5e
remove another ugly log message from query compiler
gavinking Jul 13, 2025
f3baef5
disable TRACE logging from type registries
gavinking Jul 13, 2025
a9f8e4b
disable TRACE logging from SqmFunctionRegistry
gavinking Jul 13, 2025
b78d8ef
Big clean up around natural id stuff
gavinking Jul 13, 2025
4e9d3a8
minor optimizations to logging and comments in event handlers
gavinking Jul 13, 2025
af4342b
minor aesthetic cleanups in batch loader logging
gavinking Jul 14, 2025
363308a
misc very minor consistency fixes for logging
gavinking Jul 14, 2025
41fcfa0
migrate QueryResultsCacheImpl logging to SecondLevelCacheLogger
gavinking Jul 14, 2025
c041ec4
introduce new infoString methods for batch loaders
gavinking Jul 14, 2025
4404d9c
fix jdoc of QueryResultsCacheImpl
gavinking Jul 14, 2025
1c8dcc2
use typesafe logging for all L2 cache stuff
gavinking Jul 14, 2025
7d892c5
Use L2CACHE_LOGGER from o.h.cache.spi.support
gavinking Jul 14, 2025
f0aa4d1
LazyInitializationException probably shouldn't log from its constructor
gavinking Jul 14, 2025
fe2893d
very minor cleanups
gavinking Jul 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public void integrate(
SessionFactoryServiceRegistry serviceRegistry) {
// As you might expect, an EventListenerRegistry is the thing with which event listeners are registered It is a
// service so we look it up using the service registry
final EventListenerRegistry eventListenerRegistry = serviceRegistry.getService( EventListenerRegistry.class );
final EventListenerRegistry eventListenerRegistry = sessionFactory.getEventListenerRegistry();

// If you wish to have custom determination and handling of "duplicate" listeners, you would have to add an
// implementation of the org.hibernate.event.service.spi.DuplicationStrategy contract like this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
*/
package org.hibernate;

import org.hibernate.internal.CoreMessageLogger;

import org.jboss.logging.Logger;

import java.lang.invoke.MethodHandles;

/**
* Indicates an attempt to access unfetched data outside the context
* of an open stateful {@link Session}.
Expand All @@ -25,20 +19,13 @@
*/
public class LazyInitializationException extends HibernateException {

private static final CoreMessageLogger LOG = Logger.getMessageLogger(
MethodHandles.lookup(),
CoreMessageLogger.class,
LazyInitializationException.class.getName()
);

/**
* Constructs a {@code LazyInitializationException} using the given message.
*
* @param message A message explaining the exception condition
*/
public LazyInitializationException(String message) {
super( message );
LOG.trace( message, this );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class ArchiveHelper {
private static final Logger log = Logger.getLogger( ArchiveHelper.class );

/**
* Get the JAR URL of the JAR containing the given entry
* Method used in a non managed environment
* Get the JAR URL of the JAR containing the given entry.
* Method used in a non-managed environment.
*
* @param url URL pointing to the known file in the JAR
* @param entry file known to be in the JAR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private static void setupListener(ValidatorFactory validatorFactory, SessionFact
final ConfigurationService cfgService = serviceRegistry.requireService( ConfigurationService.class );
final BeanValidationEventListener listener =
new BeanValidationEventListener( validatorFactory, cfgService.getSettings(), classLoaderService );
final EventListenerRegistry listenerRegistry = serviceRegistry.requireService( EventListenerRegistry.class );
final EventListenerRegistry listenerRegistry = sessionFactory.getEventListenerRegistry();
listenerRegistry.addDuplicationStrategy( DuplicationStrategyImpl.INSTANCE );
listenerRegistry.appendListeners( EventType.PRE_INSERT, listener );
listenerRegistry.appendListeners( EventType.PRE_UPDATE, listener );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,7 @@ public Properties loadProperties(String resourceName) {
stream.close();
}
catch (IOException e) {
log.debug(
String.format( "Unable to close properties file [%s] stream", resourceName ),
e
);
log.debug( "Unable to close properties file stream [" + resourceName + "]", e );
}
}
}
Expand All @@ -157,10 +154,7 @@ public Properties loadProperties(File file) {
stream.close();
}
catch (IOException e) {
log.debug(
String.format( "Unable to close properties file [%s] stream", file.getAbsolutePath() ),
e
);
log.debug( "Unable to close properties file stream [" + file.getAbsolutePath() + "]", e );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,28 +307,43 @@ public void addAttributeConverterDescriptor(ConverterDescriptor<?,?> descriptor)
}
}

void injectJpaTempClassLoader(ClassLoader jpaTempClassLoader) {
log.debugf( "Injecting JPA temp ClassLoader [%s] into BootstrapContext; was [%s]", jpaTempClassLoader, this.getJpaTempClassLoader() );
this.classLoaderAccess.injectTempClassLoader( jpaTempClassLoader );
void injectJpaTempClassLoader(ClassLoader classLoader) {
if ( log.isTraceEnabled() && classLoader != getJpaTempClassLoader() ) {
log.tracef( "Injecting JPA temp ClassLoader [%s] into BootstrapContext; was [%s]",
classLoader, getJpaTempClassLoader() );
}
this.classLoaderAccess.injectTempClassLoader( classLoader );
}

void injectScanOptions(ScanOptions scanOptions) {
log.debugf( "Injecting ScanOptions [%s] into BootstrapContext; was [%s]", scanOptions, this.scanOptions );
if ( log.isTraceEnabled() && scanOptions != this.scanOptions ) {
log.tracef( "Injecting ScanOptions [%s] into BootstrapContext; was [%s]",
scanOptions, this.scanOptions );
}
this.scanOptions = scanOptions;
}

void injectScanEnvironment(ScanEnvironment scanEnvironment) {
log.debugf( "Injecting ScanEnvironment [%s] into BootstrapContext; was [%s]", scanEnvironment, this.scanEnvironment );
if ( log.isTraceEnabled() && scanEnvironment != this.scanEnvironment ) {
log.tracef( "Injecting ScanEnvironment [%s] into BootstrapContext; was [%s]",
scanEnvironment, this.scanEnvironment );
}
this.scanEnvironment = scanEnvironment;
}

void injectScanner(Scanner scanner) {
log.debugf( "Injecting Scanner [%s] into BootstrapContext; was [%s]", scanner, this.scannerSetting );
if ( log.isTraceEnabled() && scanner != this.scannerSetting ) {
log.tracef( "Injecting Scanner [%s] into BootstrapContext; was [%s]",
scanner, scannerSetting );
}
this.scannerSetting = scanner;
}

void injectArchiveDescriptorFactory(ArchiveDescriptorFactory factory) {
log.debugf( "Injecting ArchiveDescriptorFactory [%s] into BootstrapContext; was [%s]", factory, this.archiveDescriptorFactory );
if ( log.isTraceEnabled() && factory != archiveDescriptorFactory ) {
log.tracef( "Injecting ArchiveDescriptorFactory [%s] into BootstrapContext; was [%s]",
factory, archiveDescriptorFactory );
}
this.archiveDescriptorFactory = factory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public ClassLoaderAccessImpl(ClassLoaderService classLoaderService) {
}

public void injectTempClassLoader(ClassLoader jpaTempClassLoader) {
log.debugf( "ClassLoaderAccessImpl#injectTempClassLoader(%s) [was %s]", jpaTempClassLoader, this.jpaTempClassLoader );
this.jpaTempClassLoader = jpaTempClassLoader;
}

Expand All @@ -55,20 +54,19 @@ public Class<?> classForName(String name) {
return classLoaderService.classForName( name );
}
else {
log.debugf( "Not known whether passed class name [%s] is safe", name );
// Could not determine that the given class is safe to load with live ClassLoader
if ( jpaTempClassLoader == null ) {
log.debugf(
"No temp ClassLoader provided; using live ClassLoader " +
"for loading potentially unsafe class : %s",
log.tracef(
"No temp ClassLoader provided; using live ClassLoader to load potentially unsafe class: %s",
name
);
return classLoaderService.classForName( name );
}
else {
log.debugf(
"Temp ClassLoader was provided, so we will use that : %s",
name
);
// log.tracef(
// "Temp ClassLoader was provided, so we will use that: %s",
// name
// );
try {
return jpaTempClassLoader.loadClass( name );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -903,9 +903,9 @@ public void addImport(String importName, String className) {
throw new IllegalArgumentException( "Import name or entity name is null" );
}
log.tracev( "Import: {0} -> {1}", importName, className);
String old = imports.put( importName, className);
final String old = imports.put( importName, className);
if ( old != null ) {
log.debugf( "import name [%s] overrode previous [{%s}]", importName, old );
log.debugf( "Import name [%s] overrode previous [{%s}]", importName, old );
}
}

Expand Down Expand Up @@ -1953,7 +1953,7 @@ protected void secondPassCompileForeignKeys(Table table, Set<ForeignKey> done, M

private void processPropertyReferences() {
if ( delayedPropertyReferenceHandlers != null ) {
log.debug( "Processing association property references" );
log.trace( "Processing association property references" );

for ( DelayedPropertyReferenceHandler delayedPropertyReferenceHandler : delayedPropertyReferenceHandlers ) {
delayedPropertyReferenceHandler.process( this );
Expand Down Expand Up @@ -2107,7 +2107,7 @@ private void handleIdentifierValueBinding(
// by tools. We want to hold off requiring classes being present until we
// try to build the SF. Here, just building the Metadata, it is "ok" for an
// exception to occur, the same exception will happen later as we build the SF.
log.debugf( "Ignoring exception thrown when trying to build IdentifierGenerator as part of Metadata building", e );
log.debug( "Ignoring exception thrown when trying to build IdentifierGenerator as part of Metadata building", e );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,9 @@ public void initSessionFactory(SessionFactoryImplementor sessionFactory) {
// must not use BootstrapContext services here
final ServiceRegistryImplementor registry = sessionFactory.getServiceRegistry();
assert registry != null;
final ConfigurationService configurationService =
registry.requireService( ConfigurationService.class );
final ClassLoaderService classLoaderService =
registry.requireService( ClassLoaderService.class );
final EventListenerRegistry eventListenerRegistry =
registry.requireService( EventListenerRegistry.class );
final ConfigurationService configurationService = registry.requireService( ConfigurationService.class );
final ClassLoaderService classLoaderService = registry.requireService( ClassLoaderService.class );
final EventListenerRegistry eventListenerRegistry = sessionFactory.getEventListenerRegistry();
configurationService.getSettings().forEach( (propertyName, value) -> {
if ( propertyName.startsWith( EVENT_LISTENER_PREFIX ) ) {
final String eventTypeName = propertyName.substring( EVENT_LISTENER_PREFIX.length() + 1 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ private <X extends T> Binding<X> doBind(XMLEventReader eventReader, Origin origi
}
catch (Exception e) {
log.debug( "Unable to close StAX reader", e );

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ private static void writeSerFile(Serializable binding, File xmlFile, File serFil
binding = (Serializable) bindingWrapper.getRoot();
}
try ( FileOutputStream fos = new FileOutputStream( serFile ) ) {
if ( log.isDebugEnabled() ) {
log.debugf( "Writing cache file for: %s to: %s", xmlFile.getAbsolutePath(), serFile.getAbsolutePath() );
if ( log.isTraceEnabled() ) {
log.tracef( "Writing cache file for: %s to: %s", xmlFile.getAbsolutePath(), serFile.getAbsolutePath() );
}
SerializationHelper.serialize( binding, fos );
boolean success = serFile.setLastModified( System.currentTimeMillis() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@
Origin origin) {
final String rootElementLocalName = rootElementStartEvent.getName().getLocalPart();
if ( "hibernate-mapping".equals( rootElementLocalName ) ) {
if ( log.isDebugEnabled() ) {
log.debugf( "Performing JAXB binding of hbm.xml document : %s", origin.toString() );
if ( log.isTraceEnabled() ) {
log.tracef( "Performing JAXB binding of hbm.xml document: %s", origin.toString() );

Check failure

Code scanning / CodeQL

Insertion of sensitive information into log files High

This
potentially sensitive information
is written to a log file.
}

final XMLEventReader hbmReader = new HbmEventReader( staxEventReader, xmlEventFactory );
Expand All @@ -181,7 +181,7 @@
else {
assert "entity-mappings".equals( rootElementLocalName );
try {
log.debugf( "Performing JAXB binding of orm.xml document : %s", origin.toString() );
log.tracef( "Performing JAXB binding of orm.xml document: %s", origin.toString() );

Check failure

Code scanning / CodeQL

Insertion of sensitive information into log files High

This
potentially sensitive information
is written to a log file.

final XMLEventReader reader = new MappingEventReader( staxEventReader, xmlEventFactory );
final JaxbEntityMappingsImpl bindingRoot = jaxb(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@

import org.hibernate.boot.MappingNotFoundException;
import org.hibernate.boot.archive.spi.InputStreamAccess;
import org.hibernate.boot.jaxb.JaxbLogger;
import org.hibernate.boot.jaxb.Origin;
import org.hibernate.boot.jaxb.SourceType;
import org.hibernate.boot.jaxb.spi.XmlSource;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;

import org.w3c.dom.Document;

import static org.hibernate.boot.jaxb.JaxbLogger.JAXB_LOGGER;

/**
* Helper for building and handling {@link XmlSource} references.
* <p>
Expand All @@ -38,7 +39,7 @@
* Create an {@link XmlSource} from a named resource
*/
public static XmlSource fromResource(String resourceName, ClassLoaderService classLoaderService) {
JaxbLogger.JAXB_LOGGER.tracef( "reading mappings from resource : %s", resourceName );
JAXB_LOGGER.tracef( "Reading mappings from resource: %s", resourceName );

Check failure

Code scanning / CodeQL

Insertion of sensitive information into log files High

This
potentially sensitive information
is written to a log file.

final Origin origin = new Origin( SourceType.RESOURCE, resourceName );
final URL url = classLoaderService.locateResource( resourceName );
Expand All @@ -54,15 +55,15 @@
*/
public static XmlSource fromUrl(URL url) {
final String urlExternalForm = url.toExternalForm();
JaxbLogger.JAXB_LOGGER.tracef( "Reading mapping document from URL : %s", urlExternalForm );
JAXB_LOGGER.tracef( "Reading mapping document from URL: %s", urlExternalForm );

final Origin origin = new Origin( SourceType.URL, urlExternalForm );
return new UrlXmlSource( origin, url );
}

public static XmlSource fromFile(File file) {
final String filePath = file.getPath();
JaxbLogger.JAXB_LOGGER.tracef( "reading mappings from file : %s", filePath );
JAXB_LOGGER.tracef( "Reading mappings from file: %s", filePath );

final Origin origin = new Origin( SourceType.FILE, filePath );

Expand All @@ -87,29 +88,29 @@

public static XmlSource fromCacheableFile(File file, File cacheableDir, boolean strict) {
final String filePath = file.getPath();
JaxbLogger.JAXB_LOGGER.tracef( "reading mappings from cacheable-file : %s", filePath );
JAXB_LOGGER.tracef( "Reading mappings from cacheable file: %s", filePath );

final Origin origin = new Origin( SourceType.FILE, filePath );
return new CacheableFileXmlSource( origin, file, cacheableDir, strict );
}

public static XmlSource fromStream(InputStreamAccess inputStreamAccess) {
final String streamName = inputStreamAccess.getStreamName();
JaxbLogger.JAXB_LOGGER.tracef( "reading mappings from InputStreamAccess : %s", streamName );
JAXB_LOGGER.tracef( "Reading mappings from InputStreamAccess: %s", streamName );

final Origin origin = new Origin( SourceType.INPUT_STREAM, streamName );
return new InputStreamAccessXmlSource( origin, inputStreamAccess );
}

public static XmlSource fromStream(InputStream inputStream) {
JaxbLogger.JAXB_LOGGER.trace( "reading mappings from InputStream" );
JAXB_LOGGER.trace( "reading mappings from InputStream" );

final Origin origin = new Origin( SourceType.INPUT_STREAM, null );
return new InputStreamXmlSource( origin, inputStream, false );
}

public static XmlSource fromDocument(Document document) {
JaxbLogger.JAXB_LOGGER.trace( "reading mappings from DOM" );
JAXB_LOGGER.trace( "reading mappings from DOM" );
final Origin origin = new Origin( SourceType.DOM, Origin.UNKNOWN_FILE_PATH );
return new JaxpSourceXmlSource( origin, new DOMSource( document ) );
}
Expand All @@ -125,7 +126,7 @@
* @param consumer a consumer of the resulting {@linkplain XmlSource XML sources}
*/
public static void fromJar(File jar, Consumer<XmlSource> consumer) {
JaxbLogger.JAXB_LOGGER.tracef( "Seeking mapping documents in jar file : %s", jar.getName() );
JAXB_LOGGER.tracef( "Seeking mapping documents in jar file: %s", jar.getName() );

final Origin origin = new Origin( SourceType.JAR, jar.getAbsolutePath() );

Expand All @@ -134,7 +135,7 @@
while ( entries.hasMoreElements() ) {
final JarEntry jarEntry = entries.nextElement();
if ( jarEntry.getName().endsWith(".hbm.xml") ) {
JaxbLogger.JAXB_LOGGER.tracef( "Found hbm.xml mapping in jar : %s", jarEntry.getName() );
JAXB_LOGGER.tracef( "Found 'hbm.xml' mapping in jar: %s", jarEntry.getName() );
consumer.accept( new JarFileEntryXmlSource( origin, jarFile, jarEntry ) );
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public Object resolveEntity(String publicID, String systemID, String baseURI, St
log.tracef( "In resolveEntity(%s, %s, %s, %s)", publicID, systemID, baseURI, namespace );

if ( namespace != null ) {
log.debugf( "Interpreting namespace : %s", namespace );
log.tracef( "Interpreting namespace: %s", namespace );
if ( MappingXsdSupport.latestDescriptor().getNamespaceUri().matches( namespace ) ) {
return openUrlStream( MappingXsdSupport.latestDescriptor() );
}
Expand Down Expand Up @@ -84,7 +84,7 @@ else if ( ConfigXsdSupport.cfgXsd().getNamespaceUri().matches( namespace ) ) {
}

if ( publicID != null || systemID != null ) {
log.debugf( "Checking public/system identifiers `%s`/`%s` as DTD references", publicID, systemID );
log.tracef( "Checking public/system identifiers `%s`/`%s` as DTD references", publicID, systemID );

if ( MAPPING_DTD.matches( publicID, systemID ) ) {
return openUrlStream( MAPPING_DTD.localSchemaUrl );
Expand Down Expand Up @@ -116,15 +116,15 @@ else if ( ConfigXsdSupport.cfgXsd().getNamespaceUri().matches( namespace ) ) {
if ( systemID != null ) {
// technically, "classpath://..." identifiers should only be declared as SYSTEM identifiers
if ( systemID.startsWith( CLASSPATH_EXTENSION_URL_BASE ) ) {
log.debugf( "Recognized `classpath:` identifier; attempting to resolve on classpath [%s]", systemID );
log.tracef( "Recognized 'classpath:' identifier; attempting to resolve on classpath [%s]", systemID );
final String path = systemID.substring( CLASSPATH_EXTENSION_URL_BASE.length() );
// todo : for this to truly work consistently, we need access to ClassLoaderService
final InputStream stream = resolveInLocalNamespace( path );
if ( stream == null ) {
log.debugf( "Unable to resolve [%s] on classpath", systemID );
log.tracef( "Unable to resolve [%s] on classpath", systemID );
}
else {
log.debugf( "Resolved [%s] on classpath", systemID );
log.tracef( "Resolved [%s] on classpath", systemID );
}
return stream;
}
Expand Down
Loading