memcached Logging
For reasons now relegated to history, Spy has its own logging implementation. However, it is compatible with other types of logging, if configured as such.
Logging Howto
spymemcached is built on top of an internal logging API that has some nice logging abstractions built in. It's analogous to what you might find in Apache's commons-logging, except Dustin had his for quite a while before finding that one.
Both log4j and Java's built-in logging are supported. The logger is selected via the system propertynet.spy.memcached.compat.log.LoggerImpl.
Using log4j
Set the logger impl to net.spy.log.Log4JLogger. For example:
-Dnet.spy.log.LoggerImpl=net.spy.memcached.compat.log.Log4JLogger
Using Java's Built-in Logging
Set the logger impl to net.spy.memcached.compat.log.SunLogger. For example:
-Dnet.spy.log.LoggerImpl=net.spy.memcached.compat.log.SunLogger
This can also be done programmatically, as shown below.
If you're writing a simple application, say a test, and you simply want to get the default console handler to be more verbose, you can set that up like so:
// Tell spy to use the SunLogger
Properties systemProperties = System.getProperties();
systemProperties.put("net.spy.log.LoggerImpl", "net.spy.memcached.compat.log.SunLogger");
System.setProperties(systemProperties); Logger.getLogger("net.spy.memcached").setLevel(Level.FINEST); //get the top Logger
Logger topLogger = java.util.logging.Logger.getLogger(""); // Handler for console (reuse it if it already exists)
Handler consoleHandler = null;
//see if there is already a console handler
for (Handler handler : topLogger.getHandlers()) {
if (handler instanceof ConsoleHandler) {
//found the console handler
consoleHandler = handler;
break;
}
} if (consoleHandler == null) {
//there was no console handler found, create a new one
consoleHandler = new ConsoleHandler();
topLogger.addHandler(consoleHandler);
} //set the console handler to fine:
consoleHandler.setLevel(java.util.logging.Level.FINEST);
Making Logging More Verbose with JDK Logger
Sometimes, you want to log what's happening with the internals of spymemcached, but not for every class. An easy way to do that is to define some properties and pass in more specific logging properties. For instance, if you start the JVM with -Djava.util.logging.config.file=logging.properties defined and then put the text below in a file named logging.properties in your classpath, you can log for just the net.spymemcached.vbucket classes.
net.spy.memcached.vbucket.level = FINEST
---
Attribution: The java.util.logging method of getting the consoleHandler was borrowed from this stackoverflow thread
memcached Logging的更多相关文章
- Python自动化 【第十一篇】:Python进阶-RabbitMQ队列/Memcached/Redis
本节内容: RabbitMQ队列 Memcached Redis 1. RabbitMQ 安装 http://www.rabbitmq.com/install-standalone-mac.htm ...
- Memcached缓存瓶颈分析
Memcached缓存瓶颈分析 获取Memcached的统计信息 Shell: # echo "stats" | nc 127.0.0.1 11211 PHP: $mc = new ...
- 代码中实际运用memcached——java
以下文章取自:http://jameswxx.iteye.com/blog/1168711 memcached的java客户端有好几种,http://code.google.com/p/memcach ...
- NET Core2.0 Memcached踩坑,基于EnyimMemcachedCore整理MemcachedHelper帮助类。
DotNetCore2.0下使用memcached缓存. Memcached目前微软暂未支持,暂只支持Redis,由于项目历史原因,先用博客园开源项目EnyimMemcachedCore,后续用到的时 ...
- Asp.Net Core 2.0 项目实战(9) 日志记录,基于Nlog或Microsoft.Extensions.Logging的实现及调用实例
本文目录 1. Net下日志记录 2. NLog的使用 2.1 添加nuget引用NLog.Web.AspNetCore 2.2 配置文件设置 2.3 依赖配置及调用 ...
- memcached command
http://lzone.de/cheat-sheet/memcached memcached Cheat Sheet Telnet Interface How To Connect Use &quo ...
- java集成memcached、redis防止缓存穿透
下载相关jar,安装Memcached,安装教程:http://www.runoob.com/memcached/memcached-install.html spring配置memcached &l ...
- Docker部署Django项目+Nginx+Fluend日志收集 和redis、memcached、RabbitMQ、Celery
前言 一.docker 1.docker是什么? Docker的英文本意是“搬运工”,Docker搬运的是集装箱(Container)可以成为容器,我可以把写的Django的WEB应用以及Python ...
- Tomcat通过Memcached实现session共享的完整部署记录
对于web应用集群的技术实现而言,最大的难点就是:如何能在集群中的多个节点之间保持数据的一致性,会话(Session)信息是这些数据中最重要的一块.要实现这一点, 大体上有两种方式:一种是把所有Ses ...
随机推荐
- 网页计算器,(类,隐藏域,style=display:block等)
第一个文件:表单文件 <html> <head><meta http-equiv="content-type" content="text/ ...
- 百度地图Api详解之地图标注
标注概述 标注(Marker)是用来表示一个点位置的可见元素,每个标注自身都包含地理信息.比如你在西单商场位置添加了一个标注,不论地图移动.缩放,标注都会跟随一起移动,保证其始终指向正确的地理位置. ...
- linux静态与动态库创建及使用实例
一,gcc基础语法: 基本语法结构:(由以下四部分组成) gcc -o 可执行文件名 依赖文件集(*.c/*.o) 依赖库文件及其头文件集(由-I或-L与-l指明) gcc 依赖文件集(*.c/*.o ...
- hdu 4876(剪枝+暴力)
题意:给定n,k,l,接下来给出n个数,让你从n个数中选取k个数围成一圈,然后从这k个数中随意选出连续的m(m>=1&&m<=k)个数进行异或后得到[l,r]区间的所有值, ...
- kali工具学习
使用前的准备 开启/关闭 HTTP服务 Service apache2 start/stop 自动启动HTTP服务:update-rc.d apache2 defaults 开启/关闭 mysql S ...
- 二叉树的基本操作(C)
实现二叉树的创建(先序).递归及非递归的先.中.后序遍历 请按先序遍历输入二叉树元素(每个结点一个字符,空结点为'='): ABD==E==CF==G== 先序递归遍历: A B D E C F G ...
- D.xml
pre{ line-height:1; color:#1e1e1e; background-color:#f0f0f0; font-size:16px;}.sysFunc{color:#627cf6; ...
- ren
- backbone-1.3.3源码解析-----------Event
第一次写,写的不对的请指正 backbone.js中的Event实现了自定义事件.自定义事件就是一个对象的键值对,key为事件名,value为一个function数组.在backbone这个对象中有一 ...
- 10分钟搞定react-router
1.路由的安装: $ npm install -S react-router 2.引入路由文件 import {Router, Route, browserHistory} from 'react-r ...