There is no easy way to write a JMeter variable into a standard log file. Also the flexible file writer is not able to use calculated variables into the log file. The flexible file writer is only able to use the properties of the previous sampler. These properties are fixed. So I use a small hack to implement this functionality in Jmeter.
First is calculate a variable called CACHE_INFO e.g. with the regular expression extractor.
Second, I use the BeanShell PostProcessor to overwrite an unused property, here I use ThreadName, of the previous sampler.
Third, I use this abused sampler property with the flexible file writer.