You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2020/12/30 03:35:27 UTC

[james-project] 15/29: [Doc] Adding a Kubernetes section for logging with James and FluentBit

This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 6fe0b3e176ebfded2d045957d46949a6886041d0
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Tue Dec 29 10:56:58 2020 +0700

    [Doc] Adding a Kubernetes section for logging with James and FluentBit
---
 .../servers/pages/distributed/operate/logging.adoc | 63 +++++++++++++++++-----
 1 file changed, 51 insertions(+), 12 deletions(-)

diff --git a/docs/modules/servers/pages/distributed/operate/logging.adoc b/docs/modules/servers/pages/distributed/operate/logging.adoc
index 234aaf1..39d0d7c 100644
--- a/docs/modules/servers/pages/distributed/operate/logging.adoc
+++ b/docs/modules/servers/pages/distributed/operate/logging.adoc
@@ -115,6 +115,8 @@ Configuration for pushing log direct to ElasticSearch
 
 === Using FluentBit as a log forwarder
 
+==== Using Docker
+
 Distributed Server leverages the use of MDC in order to achieve structured logging, and better add context to the logged information. We furthermore ship json logs to file with RollingFileAppender on the classpath to easily allow FluentBit to directly tail the log file.
 Here is a sample conf/logback.xml configuration file for logback with the following pre-requisites:
 
@@ -152,19 +154,10 @@ Centralize logging third party like FluentBit can tail from logging’s file the
                 </encoder>
         </appender>
 
-        <root level="INFO"><appender-ref ref="LOG_FILE" />
-        </root>
-
-        <root level="DEBUG"><appender-ref ref="LOG_FILE" />
-        </root>
-
-        <root level="WARN">
-                <appender-ref ref="LOG_FILE" />
+        <root level="INFO">
+            <appender-ref ref="LOG_FILE" />
         </root>
 
-        <logger name="org.apache.james" level="INFO" />
-        <logger name="com.datastax.driver.core.QueryLogger.SLOW" level="DEBUG" />
-
 </configuration>
 ....
 
@@ -292,4 +285,50 @@ FluentBit Parser config:
   Decode_Field_As   escaped_utf8    log    do_next
   Decode_Field_As   escaped         log    do_next
   Decode_Field_As   json            log
-....
\ No newline at end of file
+....
+
+==== Using Kubernetes
+
+If using James in a Kubernetes environment, you can just append the logs to the console in a JSON formatted way 
+using Jackson to easily allow FluentBit to directly tail them.
+
+Here is a sample conf/logback.xml configuration file for achieving this:
+
+....
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+
+        <contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
+                <resetJUL>true</resetJUL>
+        </contextListener>
+
+        <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+                <encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
+                    <layout class="ch.qos.logback.contrib.json.classic.JsonLayout">
+                        <timestampFormat>yyyy-MM-dd'T'HH:mm:ss.SSSX</timestampFormat>
+                        <timestampFormatTimezoneId>Etc/UTC</timestampFormatTimezoneId>
+
+                        <!-- Importance for handling multiple lines log -->
+                        <appendLineSeparator>true</appendLineSeparator>
+
+                        <jsonFormatter class="ch.qos.logback.contrib.jackson.JacksonJsonFormatter">
+                            <prettyPrint>false</prettyPrint>
+                        </jsonFormatter>
+                    </layout>
+                </encoder>
+        </appender>
+
+        <root level="INFO">
+                <appender-ref ref="CONSOLE" />
+        </root>
+
+</configuration>
+....
+
+Regarding FluentBit on Kubernetes, you need to install it as a DaemonSet. Some official template exist 
+with FluentBit outputting logs to ElasticSearch. For more information on how to install it,
+with your cluster, you can look at this https://docs.fluentbit.io/manual/installation/kubernetes[documentation].
+
+As stated by the https://docs.fluentbit.io/manual/installation/kubernetes#details[detail] of the
+official documentation, FluentBit is configured to consume out of the box logs from containers
+on the same running node. So it should scrap your James logs without extra configuration.


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org