Oh shut up, cfmemcached!
Over the last few months, our use of memcached has not so much grown but more like exploded. The cfmemcached project on RIAForge has been a great starter for us. The author is using spymemcached, a very useful memcached client implementation for Java.
As much as I immediately fell in love with cfmemcached as a developer, the admin in me began to be seriously annoyed by the underlying spymemcached's chattyness that was filling up my ColdFusion server log with useless babble about each and every connection it had with the memcached servers:
2010-04-01 14:28:43.569 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=/192.168.222.80:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, t
oWrite=0, interested=0} to connect queue
2010-04-01 14:28:43.570 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=/192.168.222.81:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, t
oWrite=0, interested=0} to connect queue
2010-04-01 14:28:43.576 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@5081e9d3
2010-04-01 14:28:43.577 INFO net.spy.memcached.MemcachedConnection: Connection state changed for sun.nio.ch.SelectionKeyImpl@11e44f0
2010-04-01 14:28:59.476 INFO net.spy.memcached.MemcachedConnection: Added {QA sa=/192.168.222.80:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, t
oWrite=0, interested=0} to connect queue
2010-04-01 17:02:37.723 INFO net.spy.memcached.transcoders.SerializingTranscoder: Compressed java.lang.String from 20798 to 4387
2010-04-01 17:02:37.731 INFO net.spy.memcached.transcoders.SerializingTranscoder: Compressed java.lang.String from 55548 to 9819
2010-04-01 17:02:41.866 INFO net.spy.memcached.transcoders.SerializingTranscoder: Compressed java.lang.String from 391919 to 45429
etc.
After a bit of research I discovered that this beast can be configured to use Log4J and I could thus shut it up quite nicely. All that is necessary are a few additions to our jvm.config and a Log4J-properties-file.
I've got a CF multi-instance install in /opt/jrun4/. I modified the jvm.config in the bin subdirectory of my installation and added the following to the java.args-line:
-Dnet.spy.log.LoggerImpl=net.spy.memcached.compat.log.Log4JLogger -Dlog4j.configuration=file:/opt/jrun4/bin/log4j.properties
(please note that there are no linebreaks in here!)
Then I created the log4j.properties-file in /opt/jrun4/bin/. This contains just two lines so far:
log4j.rootCategory=info log4j.category.net.spy.memcached=warn
After a restart of the instance, no more chatter. Enjoy the silence!