Dear ivy team support,

Currently, I'm doing some configuration for the ivy log in GCP environment. Here is my config:


 <appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
  <param name="Threshold" value="INFO"/>
  <param name="Target" value="System.out" />
  <layout class="ch.ivyteam.log.layout.IvyLog4jLayout">
      <param name="DateFormat" value="yyyy-MM-dd HH:mm:ss.SSS"/>
    </layout>
  <filter class="org.apache.log4j.varia.LevelRangeFilter">
    <param name="LevelMin" value="INFO"/>
    <param name="LevelMax" value="WARN"/>
    <param name="AcceptOnMatch" value="true"/>
  </filter>
</appender>

<!-- appender that writes log messages with priority ERROR or higher to stderr -->
<appender name="ConsoleAppenderError" class="org.apache.log4j.ConsoleAppender">
  <param name="Threshold" value="ERROR"/>
  <param name="Target" value="System.err" />
  <layout class="ch.ivyteam.log.layout.IvyLog4jLayout">
      <param name="DateFormat" value="yyyy-MM-dd HH:mm:ss.SSS"/>
    </layout>
</appender>

  <!-- Disable CXF warning at startup (missing META-INF/cxf/cxf.xml) -->
  <category name="org.apache.cxf.bus.spring" class="ch.ivyteam.log.Logger">
    <priority value="ERROR"/>
  </category>

But I got the problem: With the exception, it will print each line of exception in the stackDriver log like this picture:


We use fluentd and Stackdriver to display the log.
As I understood, we have 2 steps to display the log in the GCP

  1. Step 1: Base on the configuration in the log4jconfig.xml, Ivy will print the log to the console with the corresponding format so that fluentd can read it and display in the log view
  2. Step 2: fluentd will read that log and display in the log view.

When I check step 2, it is correct because the fluentd displayed exactly the result of step 1.
But step 1 got a problem, it prints incorrectly the entry log. I have 1 block exception but it prints to multiline log entries.
My expectation: each exception case will be visualized by only 1 entry log so that developer can easier trace the exception reason and find the solution.
Could you please give me some advice?

Thank you

asked 30.06.2020 at 00:38

nndiem's gravatar image

nndiem
(suspended)
accept rate: 0%

edited 08.07.2020 at 21:57

Hello @nndiem, as I understand your setup fluentd reads the ivy.log and passes the logs to stackdriver. So fluentd would have to read the whole stacktrace as one and not each line separately, meaning it doesn't matter what you configure in log4j, fluentd will still read it in single lines.

You could try using a fluentd plugin like this: https://github.com/GoogleCloudPlatform/fluent-plugin-detect-exceptions

Make sure the messages are caught by their java rules: https://github.com/GoogleCloudPlatform/fluent-plugin-detect-exceptions/blob/master/lib/fluent/plugin/exception_detector.rb

(09.07.2020 at 02:21) Oliver Heer Oliver%20Heer's gravatar image

I think this is a common problem of at least Java services. You can solve this problem with fluentd itself

It seems that in Log4j2 there is a configurable solution for this. It can also be done in log4j1 (current version in ivy) but it's not that easy to correctly implement it in ivy. https://stackoverflow.com/questions/38486248/how-to-make-log4j-syslog-appender-write-a-stack-trace-in-one-line/55407412#55407412

I recommend to solve it in fluentd for now. On our side we plan to upgrade to log4j2.

link

answered 13.07.2020 at 02:59

Alex%20Suter's gravatar image

Alex Suter ♦♦
3.1k122247
accept rate: 84%

edited 13.07.2020 at 03:09

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×20

Asked: 30.06.2020 at 00:38

Seen: 2,486 times

Last updated: 13.07.2020 at 03:09