I think your hunch is correct: `log4j2.properties`...
# adobe
b
I think your hunch is correct:
log4j2.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"
t
yup •
DEBUG 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=EHCACHELOGFILE
ehcache documentation mentions the sl4j interface. I'm seeing this further down in the error log:
Copy code
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.
b
I am now confused as to what you're actually looking for. Your question was originally about the properties file that ColdFusion uses to configure third-party Java components. Your hunch,
log4j2.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?
t
sorry! I'm trying to track down why Ehcache isn't logging like I'm expecting it to - I see references in
coldfusion-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
WARN
but ultimately, I'm trying to log ehcache at either debug or trace level so I can see how my application is using it
in my
log4j2.properties
I now have this:
Copy code
# 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:
Copy code
###--------------- Ehcache Log Settings ------
### Set Ehcache log

logger.ehcache =TRACE, EHCACHELOGFILE
logger.ehcache.name = net.sf.ehcache
logger.ehcache.additivity = false
when I restart CF, I see it referenced in
coldfusion-error.log
, but at the very end of the file, I'm seeing:
Copy code
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.
b
No need to be sorry. It's a discussion.😀 How is your ColdFusion application using Ehcache? Are you using the Ehcache embedded in ColdFusion or any additional Ehcache libraries? What do you expect to be logged? If you use the Ehcache embedded in ColdFusion, then you won't need any additional logging. ColdFusion should then log Ehcache events to the customary ColdFusion logs.
t
it is embedded Ehcache!
am I understanding you that Ehcache should be logging to one of the existing CF log files?
b
Yes. If it isn't, then my guess is, there is probably a dependency problem (SLF4J).
t
interesting. what configuration/log file should I be looking at for that?
b
My immediate instinct is: import the SLF4J Jar for the Ehcache version in ColdFusion.
Delving into my archives, I see that my team and I did the following with ColdFusion 2018 in the year 2018-2019: 1. Stop ColdFusion 2018; 2. In ColdFusion's lib directory, replace the Ehcache JAR with the latest version, which is _ehcache-2.10.6.jar_; 3. Ensure that these versions of the following files are present in ColdFusion's lib directory: log4j-1.2.17.jar, saaj-impl-1.5.1.jar, slf4j-api-1.7.25.jar, slf4j-log4j12-1.7.25; 4. Restart ColdFusion. When I look at ColdFusion 2025's lib directory I see the following corresponding files: log4j.jar saaj.jar slf4j-api.jar slf4j-reload4j.jar (I don't expect the version of these files to have changed between ColdFusion 2023 and ColdFusion 2025) The error 'SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"' suggests that ColdFusion 2023's default settings are incomplete. In fact, the link provided (http://www.slf4j.org/codes.html#StaticLoggerBinder) does give further details. Let's look into that some more.
❤️ 1
t
I wonder if it's because this version of ehcache predates the documentation
lemme try updating the ehcache jar to the latest 2.10.*
b
I don't think it's the Ehcache version. Everything points to slf4j-api.jar and slf4j-reload4j.jar. Let's confirm something to start with: are the following files present in your /lib directory? log4j.jar saaj.jar slf4j-api.jar slf4j-reload4j.jar
t
I have... log4j.jar saaj.jar slf4j-api-1.7.12.jar slf4j-log4j12-1.7.12.jar
b
Aha! The referenced link tells us:
Copy code
Failed 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.
Is your ColdFusion 2023 up to date? What is your update level?
The most recent version is ColdFusion 2023 Update 12. If you're on an older version I would suggest you revert any changes you have made while investigating this, and apply update 12. ColdFusion updates are cumulative. So the Adobe ColdFusion Team might have solved the logging issue in one of the updates.
However, if you're having this issue on ColdFusion 2023 Update 12, then we'll have to find a way to replace or update the pair slf4j-api-1.7.12.jar and slf4j-log4j12-1.7.12.jar.
I am off-line for the rest of the day. Good luck!
❤️ 1
You are on ColdFusion 2023, but I am on ColdFusion 2025. Just to synchronize with you, • there are no SLF4J messages in my logs; • my Ehcache version is 2.10.9.2. What is yours?
<cfscript>
ehcacheProdInfo=createobject("java","net.sf.ehcache.util.ProductInfo").init();
writedump("Ehcache version: " & ehcacheProdInfo.getVersion());
</cfscript>
t
confirming I'm on CF'23 update 12.
Ehcache version: 2.10.9.2
b
It's surprising that ColdFusion 2023 puts
Ehcache 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.jar
That suggests the following test: 1. Stop ColdFusion 2023; 2. Back up the files /lib/slf4j-api-1.7.12.jar and /lib/slf4j-log4j12-1.7.12.jar to a directory outside ColdFusion; 3. Replace them with downloads of the Jar files slf4j-api-1.7.25.jar and slf4j-log4j12-1.7.25.jar ; 4. Restart ColdFusion 2023. Do you still see the SLF4J messages in the logs? 5. Run some code that makes use of Ehcache, including intentional errors. Do you get the logs you expect?
t
I'll try this out and follow up. many thanks 🙌
I tried with both 1.7.* versions and 2.* versions to no avail. I still see the SLF4J error as the last entry in
coldfusion-error.log
after a clean restart of the CF service
b
I shall install ColdFusion 2023 today. Then we're on the same page. 😀
😍 1
🤞 1
t
let me ask you: did you confirm that you could get ehcache to log in ACF 25?
b
Despite extensive tests, I have not been able to reproduce the messages that you got:
Copy code
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.
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.
t
so you don't see the
slf4j
exceptions, but you're also not able to get ehcache to log out anywhere?
b
No, I saw no SLF4J messages. The fact that you see them suggests your installation has added an incompatible library or is missing a required library. From what I now know, the SLF4J messages pertain to ColdFusion as a whole. So, I think the absence of Ehcache logs may not be related to the messages. It is likely that ColdFusion has "wrapped" most of Ehcache's configuration. If so, then ColdFusion will then have responsibility for logging Ehcache events. For example, if you run the following code,
<cfscript>
cacheKey = "someData";
cachedData = cacheGet(cacheKey,"x");
</cfscript>
you will get an error message from ColdFusion, not from Ehcache:
Copy code
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.
I do recall something else that might be relevant to your situation: FusionReactor. We used it extensively to monitor caching and cache performance.
I think we should look into your question some more. The reasons: (1) Your use-case (default use of Ehcache in Adobe ColdFusion) is different from that in my old application. So I cannot compare your experience with my experience there. I found some documentation on that application I worked on years ago. The situation there was as follows: • it was a distributed application, last run on ColdFusion 2018 Enterprise, consisting of load-balanced ColdFusion instances located on different 64-Bit Windows Server 2016 machines; • Ehcache 2.10.6 was used together with Terracotta Toolkit 4.3.6.. The required Jars for both were imported into each instance. The ehcache.xml of each instance had settings such as
<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":
😡 1
Guess who reported the bug ... yours truly.😖
I hope others - especially from Adobe - will chime in with ideas: how do you configure ColdFusion to log Ehcache events, for example, to /logs/ehcache.log?
t
how convenient that it's still To Fix! that being said, we do have access to FusionReactor in the relevant environments. how were you monitoring Ehcache usage from there?
ultimately what I need to understand is how our application is using a particular cache region - I was hopping logging would be my answer, but if I can gather that from FusionReactor, I'm all ears 👂
b
Oh, that was 5 to 7 years ago. Though I vividly remember having used FusionReactor to monitor cache, I don't remember the details. I would, if I had the FusionReactor interface before me. I have faint memories of MBean playing a part. But I'm not too sure. Nevertheless, here's a tip for you. Ask Mr. FusionReactor himself, Michael Flewitt: https://fusion-reactor.com/contact-us/. I worked closely with him in all those years, and must have consulted him on dozens of support questions. I remember him answering every single one, often offering suggestions beyond.
❤️ 1
On Ehcache logging in ColdFusion 2023, I have been able to create a proof of concept. It consists of a process whereby ColdFusion creates the file /logs/ehcache.log and writes an error message to it. The steps in the proof of concept: (1) Make sure that the following Ehcache logging properties are present in `log4j2.properties`:
# 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 more
t
nice 🙌🏻 let me take a look when I get to my desk!
b