Yuriy
Yuriy

Reputation: 1394

Replace log files with console logs in Apache NiFi Docker Container

I have a configured Docker environment and a Logging Driver which sends all logs to a logging server. For this to work with Apache NiFi all NiFi logs should be sent to StdOut and StdErr. By default NiFi Docker Container tails a nifi-app.log file, so all logs are routed to a Logging Driver. There are two issues:

  1. nifi-user.log messages are not tailed.
  2. Log files are persisted in a separate volume. I don't want the logs to be stored anywhere except my central logging server.

There is one thread here but it does not resolve anything. The real problem is that even if to set all appender-refs to CONSOLE - all messages are intercepted by a org.apache.nifi.StdOut logger line by line. Setting log level of this logger to OFF turns off logging of any messages after "Launched Apache NiFi with Process ID" entry.

Is there a way to configure NiFi Docker image to avoid storing logs into files and route them directly to standard output?

Upvotes: 2

Views: 747

Answers (1)

martin vilche
martin vilche

Reputation: 1

Replace all file logback.xml with :

<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="30 seconds">
    <shutdownHook class="ch.qos.logback.core.hook.DefaultShutdownHook" />

    <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
        <resetJUL>true</resetJUL>
    </contextListener>

    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%date %level [%thread] %logger{40} %msg%n</pattern>
        </encoder>
    </appender>

    <root level="INFO">
        <appender-ref ref="CONSOLE"/>
    </root>
</configuration>

Upvotes: 0

Related Questions