경고 로거(org.apache.zookeeper.ZooKeeper)에 대한 추가 프로그램을 찾을 수 없습니다.

경고 로거(org.apache.zookeeper.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

오류 이유를 설명해 주세요. 사육사 로그를 시스템 로그에 등록하려면 또 무엇을 해야 합니까? 감사해요.

답변1

당신은 log4j.appender.SYSLOG8. 이렇게 되면 안 된다고 확신하시나요 log4j.appender.SYSLOG?

예제 구성 블록blog.trifork.com:

log4j.rootLogger=정보, 시스템 로그

log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG.syslogHost=127.0.0.1
log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout
log4j.appender.SYSLOG.layout.conversionPattern=%d{ISO8601} %-5p [%t] %c{2} %x - %m%n
log4j.appender.SYSLOG.Facility=LOCAL1

당신은 또한 볼 수 있습니다https://stackoverflow.com/questions/33177076/escape-newlines-in-zookeeper-logs-using-log4j-1-2-syslogappender

답변2

내 문제가 해결되었습니다. 기본 프로필을 사용하는 중에 문제가 발생했습니다. 기본 구성 파일./opt/zookeeper/conf/log4j.propertise

[root@server-1 conf]# cat tmp/log4j.properties.orgin 
# Define some default values that can be overridden by system properties
#zookeeper.root.logger=DEBUG, CONSOLE, ROLLINGFILE
#zookeeper.console.threshold=DEBUG
#zookeeper.log.dir=.
#zookeeper.log.file=zookeeper.log
#zookeeper.log.threshold=ERROR
#zookeeper.tracelog.dir=.
#zookeeper.tracelog.file=zookeeper_trace.log

#
# ZooKeeper Logging Configuration
#

# Format is "<default threshold> (, <appender>)+

# DEFAULT: console appender only
log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE

# Example with rolling log file
#log4j.rootLogger=DEBUG, CONSOLE, ROLLINGFILE

# Example with rolling log file and tracing
#log4j.rootLogger=TRACE, CONSOLE, ROLLINGFILE, TRACEFILE

#
# Log ERROR level and above messages to the console
#
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=DEBUG
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n

#
# Add ROLLINGFILE to rootLogger to get log file output
#    Log DEBUG level and above messages to a log file
log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.ROLLINGFILE.Threshold=DEBUG
log4j.appender.ROLLINGFILE.File=/var/log/zookeeper/rolling.log

# Max log file size of 10MB
log4j.appender.ROLLINGFILE.MaxFileSize=10MB
# uncomment the next line to limit number of backup files
#log4j.appender.ROLLINGFILE.MaxBackupIndex=10

log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n

#
# Add TRACEFILE to rootLogger to get log file output
#    Log DEBUG level and above messages to a log file
log4j.appender.TRACEFILE=org.apache.log4j.FileAppender
log4j.appender.TRACEFILE.Threshold=TRACE
log4j.appender.TRACEFILE.File=${zookeeper.tracelog.dir}/${zookeeper.tracelog.file}

log4j.appender.TRACEFILE.layout=org.apache.log4j.PatternLayout
### Notice we are including log4j's NDC here (%x)
log4j.appender.TRACEFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L][%x] - %m%n

이 파일은 변수를 사용합니다! 변수를 모두 제거하고 rsyslog코드만 삽입했는데 확인해 보니 ROLLINGFILE괜찮습니다. 여기서 파일을 찾을 수도 있습니다log4j. 그래서 모든 변수를 제거하고 원본 코드만 넣었습니다. ‍‍‍‍

# Define some default values that can be overridden by system properties
log4j.rootLogger=INFO, SYSLOG
log4j.appender.SYSLOG=org.apache.log4j.net.SyslogAppender
log4j.appender.SYSLOG.syslogHost=192.168.26.16
log4j.appender.SYSLOG.layout=org.apache.log4j.PatternLayout
log4j.appender.SYSLOG.layout.conversionPattern=%d{ISO8601} %-5p [%t] %c{2} %x - %m%n
log4j.appender.SYSLOG.Facility=LOCAL1
log4j.appender.SYSLOG.Threshold=debug
log4j.appender.SYSLOG.FacilityPrinting=true

rsyslog구성은 다음과 같습니다/etc/rsyslog.d/zookeeper.conf

template(name="zkformat" type="list") {
  property(name="timestamp" dateFormat="rfc3339")
  constant(value=" ")
  property(name="hostname")
  constant(value=" ")
  property(name="syslogtag")
  constant(value=" ")
  property(name="msg" spifno1stsp="on" )
  property(name="msg" droplastlf="on" )
  constant(value="\n")
}
ruleset(name="zookeeper"){
        if $programname  contains 'zookeeper' or $msg contains 'zookeeper'  then {
                action(type="omfile" file="/var/log/zookeeper/zoosys.log" Template="zkformat")
        }
}
input (type="imudp" port="514" ruleset="zookeeper") 

log4j.propertise을 위한 ROLLINGFILE:

# Define some default values that can be overridden by system properties
log4j.rootLogger=INFO, ROLLINGFILE

log4j.appender.ROLLINGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.ROLLINGFILE.Threshold=DEBUG
log4j.appender.ROLLINGFILE.File=/var/log/zookeeper/rollingfile.log

log4j.appender.ROLLINGFILE.MaxFileSize=10MB
log4j.appender.ROLLINGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLINGFILE.layout.ConversionPattern=%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n

마지막으로 내 출력 파일 log:

[root@server-1 conf]# tail /var/log/zookeeper/zoosys.log    
2018-01-01T09:49:34.059426-05:00 slavedns local1:  2018-01-01 09:49:34,058 INFO  [main] zookeeper.ZooKeeper  - Client environment:user.home=/root
2018-01-01T09:49:34.060238-05:00 slavedns local1:  2018-01-01 09:49:34,059 INFO  [main] zookeeper.ZooKeeper  - Client environment:user.dir=/opt/zookeeper-3.4.10/conf
2018-01-01T09:49:34.069773-05:00 slavedns local1:  2018-01-01 09:49:34,068 INFO  [main] zookeeper.ZooKeeper  - Initiating client connection, connectString=192.168.26.16:2182 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@46f7f36a
2018-01-01T09:49:34.131923-05:00 slavedns local1:  2018-01-01 09:49:34,126 INFO  [main-SendThread(192.168.26.16:2182)] zookeeper.ClientCnxn  - Opening socket connection to server 192.168.26.16/192.168.26.16:2182. Will not attempt to authenticate using SASL (unknown error)
2018-01-01T09:49:34.230174-05:00 slavedns local1:  2018-01-01 09:49:34,227 INFO  [main-SendThread(192.168.26.16:2182)] zookeeper.ClientCnxn  - Socket connection established to 192.168.26.16/192.168.26.16:2182, initiating session
2018-01-01T09:49:34.240287-05:00 slavedns local1:  2018-01-01 09:49:34,239 INFO  [main-SendThread(192.168.26.16:2182)] zookeeper.ClientCnxn  - Session establishment complete on server 192.168.26.16/192.168.26.16:2182, sessionid = 0x260b1fa599e0002, negotiated timeout = 30000
2018-01-01T11:11:14.478194-05:00 slavedns local1:  2018-01-01 11:11:14,477 INFO  [main] zookeeper.ZooKeeper  - Session: 0x160b1f776080005 closed
2018-01-01T11:11:14.481063-05:00 slavedns local1:  2018-01-01 11:11:14,480 INFO  [main-EventThread] zookeeper.ClientCnxn  - EventThread shut down for session: 0x160b1f776080005
2018-01-01T11:11:26.424726-05:00 slavedns local1:  2018-01-01 11:11:26,423 INFO  [main] zookeeper.ZooKeeper  - Session: 0x260b1fa599e0002 closed
2018-01-01T11:11:26.424726-05:00 slavedns local1:  2018-01-01 11:11:26,424 INFO  [main-EventThread] zookeeper.ClientCnxn  - EventThread shut down for session: 0x260b1fa599e0002
[root@server-1 conf]# 

관련 정보