I have this Ehcache XML configuration:
<ehcache>
<defaultCache
maxElementsInMemory="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
overflowToDisk="false"
diskSpoolBufferSizeMB="30"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
And also, I have some packages with entities (around 150). If I deploy my application on tomcat server, there is a lot WARN messages in log:
2015-04-29 11:59:02,712 [RMI TCP Connection(3)-127.0.0.1] WARN org.hibernate.cache.ehcache.AbstractEhcacheRegionFactory - HHH020003: Could not find a specific ehcache configuration for cache named [com.company.project.entity.package.MyEntity]; using defaults.
I can write configuration for each entity -
<cache name="com.company.project.entity.package.MyEntity"
maxEntriesLocalHeap="50"
eternal="false"
overflowToDisk="false"
timeToLiveSeconds="120">
<persistence strategy="localTempSwap"/>
</cache>
But in this way, my configuration file become too large (1600 rows). I think there is exist another way to set default config to each entity and kill warn messages, but I don't know how to do it. If anybody know, please help. Many thanks.
This is the Hibernate EHCache Cache Region code that logs the warning message:
private Ehcache getCache(String name) throws CacheException {
try {
Ehcache cache = manager.getEhcache( name );
if ( cache == null ) {
LOG.unableToFindEhCacheConfiguration( name );
manager.addCache( name );
cache = manager.getEhcache( name );
LOG.debug( "started EHCache region: " + name );
}
HibernateEhcacheUtils.validateEhcache( cache );
return cache;
}
catch (net.sf.ehcache.CacheException e) {
throw new CacheException( e );
}
}
As you can see, you have two options:
ehcache.xml
file.You set the 'org.hibernate.cache.ehcache.AbstractEhcacheRegionFactory' log level to ERROR:
For Log4j2:
<Logger name="org.hibernate.cache.ehcache.AbstractEhcacheRegionFactory" level="error">
<AppenderRef ref="File"/>
</Logger>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With