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 ...
随机推荐
- WORD中如何让前两页不显示页码
WORD中如何让前两页不显示页码 上稿人:ojn 点击率: 15191 我们有时在用word编辑文档时,会遇上第一.二页无需显示页码,第三页才是正文的第一页时,该如何正确插入页码呢? 以wor ...
- C# 类的多态、结构、接口、抽象、虚函数总结
多态: 类的多态是通过在子类(派生类)中重载基类的虚方法或成员函数来实现的. 可见,重载和虚函数的重写,并在调用时用父类装箱子类对象,是实现多态的一种重要的编程方式. 接口: 接口是一种用来定义程序的 ...
- ADO.NET+Access: 2,至少一个参数没有被指定值
ylbtech-Error-ADO.NET+Access: 2,至少一个参数没有被指定值. 1.A,错误代码返回顶部 2,至少一个参数没有被指定值. 1.B,出错原因分析返回顶部 未解决 1.C, ...
- C++ STL编程轻松入门基础
C++ STL编程轻松入门基础 1 初识STL:解答一些疑问 1.1 一个最关心的问题:什么是STL 1.2 追根溯源:STL的历史 1.3 千丝万缕的联系 1.4 STL的不同实现版本 2 牛刀小试 ...
- Nginx中的upstream轮询机制介绍
Nginx中upstream有以下几种方式: 1.轮询(weight=1) 默认选项,当weight不指定时,各服务器weight相同, 每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器d ...
- delphi TeeChart保存3种图片文件
var vForm: Tfrm_ChemaShowMainChild;begin vForm := GetActiveForm; vForm.cht_Edit.SaveToMetafile('C:\1 ...
- ElasticSearch 查询语法
ElasticSearch是基于lucene的开源搜索引擎,它的查询语法关键字跟lucene一样,如下: 分页:from/size 字段:fields 排序:sort 查询:query 过滤:filt ...
- reCAPTCHA 简单分析
CAPTCHA项目是Completely Automated Public Turing Test to Tell Computers and Humans Apart (全自动区分计算机和人类的图灵 ...
- LoadRunner error -27979
4.LoadRunner请求无法找到:在录制Web协议脚本回放脚本的过程中,会出现请求无法找到的现象,而导致脚本运行停止.错误现象:Action.c(41): Error -27979: Reques ...
- Windows 下命令行修改文件夹的控制权限 Cacls
设置用户访问权限:我们经常要修改目录和文件的访问权限,使用Cacls命令就很容易做到.下面要赋予本机用户testuser对d盘下 test目录及其所有子目录中的文件有完全控制权限.在命令提示符对话框中 ...