BK BK
03/22/2025, 2:06 PMlog4j2.properties.
• log4j.properties (and logger.xml) settings are specific to log4j configuration;
• logging.properties settings configure ColdFusion's default logging behaviour server-wide;
• neo-logging.xml settings configure ColdFusion's own loggers;
Using your Ehcache example, you should see the following setting in `log4j2.properties`:
###--------------- Ehcache Log Settings ------
### Set Ehcache log
logger.ehcache =ERROR, CONSOLE
logger.ehcache.name = net.sf.ehcache
That said, it depends where you set the log level. ColdFusion might not log anything if, for example, a third-party Java application has the responsibility for logging Ehcache events.
To see the list of all the loggers of ColdFusion's Java dependencies
1. add the flag -Dlog4j2.debug=true to the java.args property in `/bin/jvm.config`;
2. restart ColdFusion 2023;
3. open coldfusion-error.log in an editor and look for lines such as "DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=7b676112,component=Loggers,name=xxx"timmixell
03/23/2025, 12:40 PMDEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=eca6a74,component=Loggers,name=net.sf.ehcache
• DEBUG StatusLogger Registering MBean org.apache.logging.log4j2:type=eca6a74,component=Appenders,name=EHCACHELOGFILEtimmixell
03/23/2025, 12:52 PMSLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See <http://www.slf4j.org/codes.html#StaticLoggerBinder> for further details.BK BK
03/23/2025, 2:28 PMlog4j2.properties, turns out to be right. That was that, I thought.
But it appears you're still searching. It is unclear to me what for.
How do you apply Ehcache within ColdFusion? What do you want to achieve with that? What issues are you facing?timmixell
03/23/2025, 2:31 PMcoldfusion-error to the log files being created, but I see no actual output in the corresponding ehcache.log file I've configured, save for a single WARNtimmixell
03/23/2025, 2:31 PMtimmixell
03/23/2025, 2:34 PMlog4j2.properties I now have this:
# ehcachelogfile is set to be a RollingFileAppender for ehcache message using a PatternLayout.
appender.ehcachelogfile.type = RollingFile
appender.ehcachelogfile.name = EHCACHELOGFILE
appender.ehcachelogfile.fileName = ${basepath}/ehcache.log
appender.ehcachelogfile.filePattern = ${basepath}/ehcache.%i.log
appender.ehcachelogfile.createOnDemand = true
appender.ehcachelogfile.layout.type = PatternLayout
appender.ehcachelogfile.layout.pattern = %d{MM/dd HH:mm:ss} [%t] EHCACHE %-5p - %m%n%n
appender.ehcachelogfile.policies.type = Policies
appender.ehcachelogfile.policies.size.type = SizeBasedTriggeringPolicy
appender.ehcachelogfile.policies.size.size=5000KB
appender.ehcachelogfile.strategy.type = DefaultRolloverStrategy
appender.ehcachelogfile.strategy.max = 5
and separately:
###--------------- Ehcache Log Settings ------
### Set Ehcache log
logger.ehcache =TRACE, EHCACHELOGFILE
logger.ehcache.name = net.sf.ehcache
logger.ehcache.additivity = falsetimmixell
03/23/2025, 2:42 PMcoldfusion-error.log, but at the very end of the file, I'm seeing:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See <http://www.slf4j.org/codes.html#StaticLoggerBinder> for further details.BK BK
03/23/2025, 2:44 PMtimmixell
03/23/2025, 2:51 PMtimmixell
03/23/2025, 2:52 PMBK BK
03/23/2025, 2:52 PMtimmixell
03/23/2025, 2:54 PMBK BK
03/23/2025, 2:55 PMBK BK
03/23/2025, 3:35 PMtimmixell
03/23/2025, 3:37 PMtimmixell
03/23/2025, 3:37 PMBK BK
03/23/2025, 4:06 PMtimmixell
03/23/2025, 4:09 PMBK BK
03/23/2025, 4:20 PMFailed to load class org.slf4j.impl.StaticLoggerBinder
This warning message is reported by slf4j-api version 1.7.x and earlier when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.BK BK
03/23/2025, 4:27 PMBK BK
03/23/2025, 4:55 PMBK BK
03/23/2025, 4:58 PMBK BK
03/23/2025, 5:00 PMBK BK
03/24/2025, 12:20 PM<cfscript>
ehcacheProdInfo=createobject("java","net.sf.ehcache.util.ProductInfo").init();
writedump("Ehcache version: " & ehcacheProdInfo.getVersion());
</cfscript>timmixell
03/24/2025, 12:23 PMEhcache version: 2.10.9.2BK BK
03/24/2025, 12:37 PMEhcache 2.10.9.2 together with slf4j-api-1.7.12.jar and slf4j-log4j12-1.7.12.jar
Ehcache documentation suggests that the correct dependency versions for Ehcache 2.10.9.2 are slf4j-api-1.7.25.jar and slf4j-log4j12-1.7.25.jarBK BK
03/24/2025, 12:58 PMtimmixell
03/24/2025, 1:00 PMtimmixell
03/24/2025, 9:38 PMcoldfusion-error.log after a clean restart of the CF serviceBK BK
03/25/2025, 9:23 AMtimmixell
03/25/2025, 10:48 AMBK BK
03/27/2025, 1:39 PMSLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See <http://www.slf4j.org/codes.html#StaticLoggerBinder> for further details.
I installed ColdFusion 2023 on Windows 10 and applied the latest update (update 12). To confirm, the installation does indeed have the files /lib/slf4j-api-1.7.12.jar and /lib/slf4j-log4j12-1.7.12.jar. But those error-messages didn't show up in the ColdFusion logs.
I then tested by including in, or excluding from, log4j2.properties the various combinations of Ehcache logging settings that we discussed earlier. I included each and every one of the settings you had used. I also tested by switching from slf4j-api-1.7.12.jar and slf4j-log4j12-1.7.12.jar to slf4j-api-1.7.25.jar and slf4j-log4j12-1.7.25.jar.
Result: no such messages in the ColdFusion logs.
Similar tests were done on ColdFusion 2025.
The result: no such messages in the ColdFusion logs.timmixell
03/27/2025, 1:40 PMslf4j exceptions, but you're also not able to get ehcache to log out anywhere?BK BK
03/27/2025, 2:58 PM<cfscript>
cacheKey = "someData";
cachedData = cacheGet(cacheKey,"x");
</cfscript>
you will get an error message from ColdFusion, not from Ehcache:
coldfusion.tagext.io.cache.CacheExceptions$CacheNotFoundException: Cache region with name x does not exist.
at coldfusion.cache.ehcache.GenericEhcache._getCache(GenericEhcache.java:435)
at coldfusion.cache.ehcache.GenericEhcache.getCache(GenericEhcache.java:342)
at coldfusion.cache.ehcache.GenericEhcache.get(GenericEhcache.java:129)
at coldfusion.tagext.io.cache.CacheTagHelper.getFromCache(CacheTagHelper.java:318)
at coldfusion.tagext.io.cache.CacheTagHelper.getFromCache(CacheTagHelper.java:306)
at coldfusion.runtime.CFPage.CacheGet(CFPage.java:16468)
That said, the question remains: how do you configure the embedded Ehcache to independently log to /some/path/ehcache.log? I remember having to answer such questions. That was over 6 years ago. So my memory of it is a bit vague.
While I worked on the application the ColdFusion upgrades ran from 2016 to 2018. To get Ehcache to log independently, we had to configure a CacheManagerEventListener. The place to do this is /lib/ehcache.xml. I remember that doing so led to a drop in performance of code involving cache. Mainly due to slow class-loading.BK BK
03/27/2025, 3:49 PMBK BK
03/28/2025, 10:11 AM<cache>
<terracotta clustered="true">
<nonstop enabled="true"/>
</terracotta>
</cache>
<terracottaConfig rejoin="true" />
• Terracotta was configured to log the cache events of the various instances, treating each instance as a client.
As this use-case is different from ColdFusion's default, I would like to go back to the beginning. Hence to your original question: how do you configure ColdFusion to log cache events, for example, to /logs/ehcache.log?
(2) The 3 SLF4J messages you've found might not be innocent after all. This was reported as a bug in ColdFusion 2023 Update 3.
See https://tracker.adobe.com/#/view/CF-4218975
Surprisingly, its status is still "To Fix":BK BK
03/28/2025, 10:31 AMBK BK
03/28/2025, 10:38 AMtimmixell
03/28/2025, 11:22 AMtimmixell
03/28/2025, 11:23 AMBK BK
03/29/2025, 2:00 PMBK BK
03/29/2025, 2:47 PM# ehcachelogfile is set to be a RollingFileAppender for Ehcache message using a PatternLayout.
appender.ehcachelogfile.type = RollingFile
appender.ehcachelogfile.name = EHCACHELOGFILE
appender.ehcachelogfile.fileName = ${basepath}/ehcache.log
appender.ehcachelogfile.filePattern = ${basepath}/ehcache.%i.log
appender.ehcachelogfile.createOnDemand = true
appender.ehcachelogfile.layout.type = PatternLayout
appender.ehcachelogfile.layout.pattern = %d{MM/dd HH:mm:ss} [%t] EHCACHE %-5p - %m%n%n
appender.ehcachelogfile.policies.type = Policies
appender.ehcachelogfile.policies.size.type = SizeBasedTriggeringPolicy
appender.ehcachelogfile.policies.size.size=5000KB
appender.ehcachelogfile.strategy.type = DefaultRolloverStrategy
appender.ehcachelogfile.strategy.max = 5
###--------------- Ehcache Log Settings ------
### Set Ehcache log
logger.ehcache =TRACE, EHCACHELOGFILE
logger.ehcache.name = net.sf.ehcache
logger.ehcache.additivity = false
(2) Create the 2 CFM files, cacheTest1.cfm and cacheTest2.cfm, in a directory under the web-root:
<!--- cacheTest1.cfm --->
<cfscript>
defaultCacheProps = StructNew();
defaultCacheProps.maxElementsInMemory = "5";
defaultCacheProps.eternal = "false";
defaultCacheProps.timeToIdleSeconds= "100";
defaultCacheProps.timeToLiveSeconds= "50";
defaultCacheProps.overflowToDisk= "true";
defaultCacheProps.diskExpiryThreadIntervalSeconds= "3600";
defaultCacheProps.diskPersistent= "false";
defaultCacheProps.diskPoolBufferSizeMB= "30";
defaultCacheProps.maxElementsOnDisk= "10";
defaultCacheProps.memoryEvictionPolicy= "LRU";
defaultCacheProps.clearOnFlush= "true";
defaultCacheProps.objectType= "Object";
// create cache region
cacheRegionName = "testregion";
cacheRegionNew(cacheRegionName,defaultCacheProps,false);
writeoutput("Cache region '" & cacheRegionName & "' successfully created");
</cfscript>
<!--- cacheTest2.cfm --->
<cfscript>
// Define cache key
cacheKey = "userData";
// Get data from cache, assuming data already in cache
cachedData = cacheGet(cacheKey);
// Check if data exists
If (not isNull(cachedData)) {
writeOutput("Cache hit! Retrieving data...<br>As the data already exists in the cache, there is no need to do a cachePut. <br>");
writedump(var=cachedData, label="Cached Data");
abort;
} else {
writeOutput("Cache miss! Caching the data using cachePut...<br>");
// Simulate a database query or expensive operation
userData = {
name = "John Doe",
email = "<mailto:john.doe@example.com|john.doe@example.com>",
lastLogin = now()
};
// Store data in cache for 3 minutes
cachePut(cacheKey, userData, 180);
writeOutput("Data cached successfully!<br>");
}
// Retrieve and display cached data
retrievedData = cacheGet(cacheKey);
writeOutput("User Name: " & retrievedData.name & "<br>");
writeOutput("Email: " & retrievedData.email & "<br>");
writeOutput("Last Login: " & retrievedData.lastLogin & "<br>");
// Uncomment the following line to remove the cache entry
// cacheRemove(cacheKey);
</cfscript>
(3) Run cacheTest1.cfm and cacheTest2.cfm in quick succession, and restart ColdFusion 2023.
You should obtain the following result:
(1) ColdFusion 2023 creates the file /logs/ehcache.log, if the file doesn't yet exist;
(2) ColdFusion writes the following to the file `/logs/ehcache.log`:
java.lang.NoClassDefFoundError: java/io/ObjectOutputStream
at net.sf.ehcache.store.disk.DiskStorageFactory$IndexWriteTask.call(DiskStorageFactory.java:1103) ~[ehcache.jar:?]
at net.sf.ehcache.store.disk.DiskStorageFactory.unbind(DiskStorageFactory.java:921) [ehcache.jar:?]
at net.sf.ehcache.store.disk.DiskStore.dispose(DiskStore.java:665) [ehcache.jar:?]
at net.sf.ehcache.store.CacheStore.dispose(CacheStore.java:342) [ehcache.jar:?]
at net.sf.ehcache.Cache.dispose(Cache.java:2586) [ehcache.jar:?]
at net.sf.ehcache.CacheManager.shutdown(CacheManager.java:1552) [ehcache.jar:?]
at coldfusion.cache.ehcache.GenericEhcache$CacheCleanUpAgent.shutdown(GenericEhcache.java:1156) [caching-2023.0.11.330706.jar:?]
at coldfusion.cache.ehcache.GenericEhcache$CacheCleanUpAgent.run(GenericEhcache.java:1121) [caching-2023.0.11.330706.jar:?]
at coldfusion.scheduling.Scheduler.run(Scheduler.java:245) [cfusion.jar:development]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassNotFoundException: java.io.ObjectOutputStream
at <http://java.net|java.net>.URLClassLoader.findClass(URLClassLoader.java:445) ~[?:?]
at coldfusion.bootstrap.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:254) ~[cfmx_bootstrap.jar:development]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
... 10 more
03/29 15:29:28 [Thread-6] ehcache ERROR - Could not flush disk cache. Initial cause was java/io/ObjectOutputStream
java.lang.NoClassDefFoundError: java/io/ObjectOutputStream
at net.sf.ehcache.store.disk.DiskStorageFactory$IndexWriteTask.call(DiskStorageFactory.java:1103) ~[ehcache.jar:?]
at net.sf.ehcache.store.disk.DiskStorageFactory.unbind(DiskStorageFactory.java:921) [ehcache.jar:?]
at net.sf.ehcache.store.disk.DiskStore.dispose(DiskStore.java:665) [ehcache.jar:?]
at net.sf.ehcache.store.CacheStore.dispose(CacheStore.java:342) [ehcache.jar:?]
at net.sf.ehcache.Cache.dispose(Cache.java:2586) [ehcache.jar:?]
at net.sf.ehcache.CacheManager.shutdown(CacheManager.java:1552) [ehcache.jar:?]
at coldfusion.cache.ehcache.GenericEhcache$CacheCleanUpAgent.shutdown(GenericEhcache.java:1156) [caching-2023.0.11.330706.jar:?]
at coldfusion.cache.ehcache.GenericEhcache$CacheCleanUpAgent.run(GenericEhcache.java:1121) [caching-2023.0.11.330706.jar:?]
at coldfusion.scheduling.Scheduler.run(Scheduler.java:245) [cfusion.jar:development]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassNotFoundException: java.io.ObjectOutputStream
... 10 moretimmixell
03/29/2025, 4:16 PMBK BK
03/29/2025, 5:42 PM