[置顶] 在tomcat日志里打印memcache日志,并实现session共享


Add memcached-session-manager jars to tomcat


添加memcache的jar包到tomcat的lib下。

 memcached-session-manager-${version}.jar

memcached-session-manager-tc6-${version}.jar for tomcat6

or memcached-session-manager-tc7-${version}.jar for tomcat7



Configure memcached-session-manager as <Context> Manager


在tomcat的conf目录下的context.xml文件中添加

<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"  
             memcachedNodes="n1:123.23.223.23:11211"            
             requestUriIgnorePattern=".*\.(png|gif|jpg|css|js)$"
              sticky="false"  //保证每次都去重新请求,如果本地已经有了,也要重新请求,避免混乱
              sessionBackupAsync="false"  
             sessionBackupTimeout="1800000"  
             copyCollectionsForSerialization="false"  
             transcoderFactoryClass="de.javakaffee.web.msm.serializer.javolution.JavolutionTranscoderFactory"  
    />

Configure logging


Add the following to $CATALINA_HOME/bin/catalina.sh:
CATALINA_OPTS="-Dnet.spy.log.LoggerImpl=net.spy.memcached.compat.log.SunLogger"



在tomcat的conf目录下的logging.properties文件中添加

#memcache log config
de.javakaffee.web.msm.level=FINE

参考文献:https://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration


你可能感兴趣的:([置顶] 在tomcat日志里打印memcache日志,并实现session共享)