Hello team I want to have my own log4j2.properties...
# troubleshooting
a
Hello team I want to have my own log4j2.properties file configured for zookeeper. I have also give file name in log4j2.properties. But logs are not getting written in that file, can someone pls help.
log4j2.properties
Copy code
status = error
name = ZooKeeperLogConfig

# Console appender configuration
appender.console.type = Console
appender.console.name = CONSOLE
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%t] [%p] [%c{1}] - %m%n

# File appender configuration
appender.file.type = File
appender.file.name = FILE
appender.file.fileName = /data/zookeeper-data/datalog/logs/zookeeper.log
appender.file.layout.type = PatternLayout
appender.file.layout.pattern = [%d{yyyy-MM-dd HH:mm:ss.SSS}] [%t] [%p] [%c{1}] - %m%n

# Root logger configuration
rootLogger.level = debug
rootLogger.appenderRefs = console, file
rootLogger.appenderRef.console.ref = CONSOLE
rootLogger.appenderRef.file.ref = FILE
docker-compose-zookeeper.yml
Copy code
version: '3'
services:
  zookeeper-1:
    image: 'zookeeper:3.8.4'
    ports:
      - "2181:2181"
      - "2888:2888"
      - "3888:3888"
      - "8081:8081"
    container_name: zookeeper-1
    environment:
      - TZ=Asia/Kolkata
      - JAVA_OPTS=-Xmx12G
#      - ZOO_LOG_CONFIG_FILE=/data/apache-zookeeper-3.8.4-bin/conf/log4j2.properties
      - JAVA_OPTS=-Xmx12G -Dlog4j.configurationFile=/data/apache-zookeeper-3.8.4-bin/conf/log4j2.properties

    volumes:
      - /data/zookeeper-data/conf/zoo.cfg:/opt/zookeeper/conf/zoo.cfg
      - /data/apache-zookeeper-3.8.4-bin/conf/log4j2.properties:/data/apache-zookeeper-3.8.4-bin/conf/log4j2.properties
      - /data/zookeeper-data/data:/data
      - /data/myid:/data/myid
      - /data/zookeeper-data/datalog/logs:/logs
    entrypoint: ["/bin/sh", "-c", "/apache-zookeeper-3.8.4-bin/bin/zkServer.sh --config /opt/zookeeper/conf start && tail -f /dev/null"]
    entrypoint: ["/bin/sh", "-c", "export JAVA_OPTS=\"$JAVA_OPTS -Dlog4j.configurationFile=/data/apache-zookeeper-3.8.4-bin/conf/log4j2.properties\" && /apache-zookeeper-3.8.4-bin/bin/zkServer.sh --config /opt/zookeeper/conf start && tail -f /dev/null"]
    restart: unless-stopped
not changed anywhere else
it is writing logs in default file of .out
@Mayank @Jackie
x
Please check with zookeeper docs for the logging section: https://zookeeper.apache.org/doc/r3.8.4/zookeeperAdmin.html#sc_logging