conductor-oss/conductor

According to the documentation, the log4j configuration file cannot be used correctly

NikulovE opened this issue · 0 comments

Describe the bug
https://github.com/conductor-oss/conductor/blob/main/docs/documentation/metrics/server.md
By reading this document, I only know that I need to add environment variables such as:
LOG4J_PROP=log4j.properties
However, I don’t know what to do next to use this environment variable to make the log take effect.
New conductor oss was switched to log4j2 with XML files
Details
Conductor version: 3.19.0

To Reproduce
Steps to reproduce the behavior:
set env LOG4J_PROP=log4j.properties

Expected behavior
Split logs to conductor.log, server.log metrics.log

Additional context
outdated file https://github.com/conductor-oss/conductor/blob/main/docker/server/config/log4j.properties
outdated file https://github.com/conductor-oss/conductor/blob/main/docker/server/config/log4j-file-appender.properties

proposed log4j2-file-appender.xml:

<Configuration status="WARN">
    <Appenders>
        <Console name="CONSOLE" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{ISO8601} %5p [%t] (%C) - %m%n"/>
        </Console>
        <RollingFile name="FILE" fileName="/app/logs/conductor.log" filePattern="/app/logs/conductor-%d{MM-dd-yyyy}.log.gz">
            <PatternLayout>
                <pattern>%d{ISO8601} %5p [%t] (%C) - %m%n</pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy />
            </Policies>
        </RollingFile>
        <RollingFile name="FILEMETRICS" fileName="/app/logs/metrics.log" filePattern="/app/logs/metrics-%d{MM-dd-yyyy}.log.gz">
            <PatternLayout>
                <pattern>%d{ISO8601} %5p [%t] (%C) - %m%n</pattern>
            </PatternLayout>
            <Policies>
                <TimeBasedTriggeringPolicy />
            </Policies>
        </RollingFile>
    </Appenders>
    <Loggers>
        <Root level="INFO">
            <AppenderRef ref="CONSOLE" />
            <AppenderRef ref="FILE" />
        </Root>
        <Logger name="ConductorMetrics" level="INFO" additivity="false">
            <AppenderRef ref="CONSOLE" />
            <AppenderRef ref="FILEMETRICS" />
        </Logger>
    </Loggers>
</Configuration>

proposed startup.sh:

`#!/bin/sh
#
#  Copyright 2021 Netflix, Inc.
#  <p>
#  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
#  the License. You may obtain a copy of the License at
#  <p>
#  http://www.apache.org/licenses/LICENSE-2.0
#  <p>
#  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
#  an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
#  specific language governing permissions and limitations under the License.
#

# startup.sh - startup script for the server docker image

echo "Starting Conductor server"

# Start the server
cd /app/libs

echo "Property file: $CONFIG_PROP"
echo $CONFIG_PROP
export config_file=

if [ -z "$CONFIG_PROP" ];
  then
    echo "Using default configuration file";
    export config_file=/app/config/config.properties
  else
    echo "Using '$CONFIG_PROP'";
    export config_file=/app/config/$CONFIG_PROP
fi

echo "Log4j property file: $LOG4J_PROP"
echo $LOG4J_PROP
export log4j_config_file=

if [ -z "$LOG4J_PROP" ];
  then
    export log4j_config_file=/app/config/log4j2.xml
    echo "Using default: '$log4j_config_file'";
  else
    echo "Using '$LOG4J_PROP'";
    export log4j_config_file=/app/config/$LOG4J_PROP
fi

echo "Using java options config: $JAVA_OPTS"

# Set the environment variable for log4j configuration file
export JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$log4j_config_file"

java ${JAVA_OPTS} -jar -DCONDUCTOR_CONFIG_FILE=$config_file conductor-server.jar 2>&1 | tee -a /app/logs/server.log