在zookeeper server的配置文件zoo.cfg中可以通过dataLogDir来配置zookeeper的事务日志的输出目录,这个事务日志类似于下面这样的文件:
这个文件是一个二进制文件, 一般不能够直接识别, 那么是否有方法可以把这些事务日志转换成正常日志文件呢, 答案是肯定的~
Zookeeper自带一个工具类:org.apache.zookeeper.server.LogFormatter, 使用这个类可以对zookeeper的事务日志进行格式化查看,
查看方法如下: java LogFormatter D:\zookeeper-3.4.3\zk_data\version-2\log.48
示例执行命令:java -cp /usr/local/zookeeper-3.4.6/bin/../build/classes:/usr/local/zookeeper-3.4.6/bin/../build/lib/*.jar:/usr/local/zookeeper-3.4.6/bin/../lib/slf4j-log4j12-1.6.1.jar:/usr/local/zookeeper-3.4.6/bin/../lib/slf4j-api-1.6.1.jar:/usr/local/zookeeper-3.4.6/bin/../lib/netty-3.7.0.Final.jar:/usr/local/zookeeper-3.4.6/bin/../lib/log4j-1.2.16.jar:/usr/local/zookeeper-3.4.6/bin/../lib/jline-0.9.94.jar:/usr/local/zookeeper-3.4.6/bin/../zookeeper-3.4.6.jar:/usr/local/zookeeper-3.4.6/bin/../src/java/lib/*.jar:/usr/local/zookeeper-3.4.6/bin/../conf:
org.apache.zookeeper.server.LogFormatter
通过这种方法,我们就可以看到类似于下面这样清晰的事务日志了~
来源:CSDN
作者:kobejayandy
链接:https://blog.csdn.net/kobejayandy/article/details/46728739