Shawyeok opened a new issue, #4136:
URL: https://github.com/apache/bookkeeper/issues/4136

   **BUG REPORT**
   The logging configuration in the Docker image is broken after #3225, which 
switched to using `log4j2.xml` instead of `log4j.properties`.
   
   In the Bookkeeper Docker image entrypoint, configuration files in the `conf` 
directory are overridden with environment variables prefixed with `BK_`. This 
configuration override mechanism ([apply-config-from-env.py][1]) affects all 
files in the `conf` directory, including `log4j2*.xml`.
   However, `apply-config-from-env.py` was not intended to override XML 
configurations, or at least it was not originally designed for this purpose. As 
a result, some lines are unexpectedly dropped after the configuration override.
   
   
https://github.com/apache/bookkeeper/blob/c07e72aabd68abec18ac761e61aec289814390c4/docker/scripts/apply-config-from-env.py#L62-L70
   
   [1]: 
https://github.com/apache/bookkeeper/blob/c07e72aabd68abec18ac761e61aec289814390c4/docker/scripts/apply-config-from-env.py
   
   ***Describe the bug***
   After start a bookie from docker image could see error message in the 
console.
   ```
   [Fatal Error] log4j2.xml:30:11: The element type "Appenders" must be 
terminated by the matching end-tag "</Appenders>".
   ERROR StatusLogger Error parsing /opt/bookkeeper/conf/log4j2.xml
    org.xml.sax.SAXParseException; systemId: 
file:///opt/bookkeeper/conf/log4j2.xml; lineNumber: 30; columnNumber: 11; The 
element type "Appenders" must be terminated by the matching end-tag 
"</Appenders>".
        at 
java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:262)
        at 
java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:342)
        at 
org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:94)
        at 
org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory.getConfiguration(XmlConfigurationFactory.java:46)
        at 
org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:499)
        at 
org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:474)
        at 
org.apache.logging.log4j.core.config.ConfigurationFactory$Factory.getConfiguration(ConfigurationFactory.java:398)
        at 
org.apache.logging.log4j.core.config.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:318)
        at 
org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:690)
        at 
org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:711)
        at 
org.apache.logging.log4j.core.LoggerContext.start(LoggerContext.java:253)
        at 
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:155)
        at 
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(Log4jContextFactory.java:47)
        at org.apache.logging.log4j.LogManager.getContext(LogManager.java:196)
        at 
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getContext(AbstractLoggerAdapter.java:137)
        at 
org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:55)
        at 
org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:47)
        at 
org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:33)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:363)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:388)
        at org.apache.bookkeeper.server.Main.<clinit>(Main.java:51)
   ERROR StatusLogger No logging configuration
   ```
   
   ***To Reproduce***
   
   Just start a bookie from docker image.
   ```
   $ docker run -it --name bookie1 \
       -e BK_bookiePort=3181 \
       -e BK_zkServers=zk-server1:2181,zk-server2:2181 \
       -e BK_journalPreAllocSizeMB=32 \
       apache/bookkeeper
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to