我在这条路径上安装了 zookeeper /opt/zookeeper
。
我zoo-1.cfg
的/opt/zookeeper/conf/
:
#Node1
dataDir=/var/zookeeper/data-1
clientPort=2181
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890
我log4j.properties
的/opt/zookeeper/conf/
:
zookeeper.root.logger=DEBUG, SYSLOG8
log4j.rootLogger=${zookeeper.root.logger}
zookeeper.log.dir=/var/log/zookeeper
zookeeper.log.file=zookeeper.log
zookeeper.log.threshold=DEBUG
zookeeper.tracelog.dir=.
zookeeper.tracelog.file=zookeeper_trace.log
#-------------------------------------------------
log4j.appender.SYSLOG8=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG8.threshold=DEBUG
log4j.appender.SYSLOG8.syslogHost=192.168.26.16
log4j.appender.SYSLOG8.facility=USER
log4j.appender.SYSLOG8.layout=org.apache.log4j.PatternLayout
log4j.appender.SYSLOG8.layout.conversionPattern=[%p] %c:%L - %m$
当我想与客户端连接时,出现此错误:
[root@server-1 bin]# sh zkCli.sh -server 127.0.0.1:2182
log4j:ERROR Could not find value for key log4j.appender.CONSOLE
log4j:ERROR Could not instantiate appender named "CONSOLE".
Connecting to 127.0.0.1:2182
log4j:WARN No appenders could be found for logger
(org.apache.zookeeper.ZooKeeper).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for
more info.
Welcome to ZooKeeper!
JLine support is enabled
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
[zk: 127.0.0.1:2182(CONNECTED) 0]
我的rsyslog.cnf
:
$ModLoad imudp
$UDPServerRun 514
$ModLoad imtcp
$InputTCPServerRun 514
*.* @192.168.26.16:514
请说明错误的原因。还需要做什么才能在 syslog 中注册 zookeeper 日志?谢谢。
你有
log4j.appender.SYSLOG8
. 你确定它不应该是log4j.appender.SYSLOG
吗?来自blog.trifork.com的示例配置块:
另请参阅https://stackoverflow.com/questions/33177076/escape-newlines-in-zookeeper-logs-using-log4j-1-2-syslogappender
我的问题已经解决了。使用默认配置文件时出现问题。默认配置文件。
/opt/zookeeper/conf/log4j.propertise
该文件使用变量!我删除了所有变量,只插入
rsyslog
代码,我也检查ROLLINGFILE
了,没关系。你甚至可以在这个log4j中找到这个文件。所以,我删除了所有变量,只放置了原始代码。我的
rsyslog
配置是:/etc/rsyslog.d/zookeeper.conf
log4j.propertise
对于ROLLINGFILE
:最后我的输出文件
log
: