Project

General

Profile

Actions

task #10072

closed

Upgrade fully to log4j2

Added by Andreas Müller about 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Priority14
Category:
cdmlib
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Severity:
normal

Description

We already upgraded to log4j2 in #9359.

However, the class eu.etaxonomy.cdm.opt.config.LoggingConfigurer is not yet updated as it is not easy to adapt.
First, wie need to check if it is still needed.
=> removed as not really needed anymore

Also we may want to use xml based configuration instead of properties (but this might be another issue). (an example is FloreDuGabon import).

Also we may want to remove slf4j-reload4j (slf4j-log4j12) as it is not needed anymore (https://www.slf4j.org/manual.html)

Also explicit setLevel() is not recommended according to https://logging.apache.org/log4j/log4j-2.1/manual/migration.html (Converting to the Log4j 2 API - 7) => I tried to remove all setLevel() calls in non-test methods. In tests performance is less critical.

Improve integration into jetty (application server) using logj-appserver (https://logging.apache.org/log4j/2.x/index.html) => #10072

Links:


Related issues

Related to EDIT - task #9205: Remove apache-log4j-extras from TaxEditor dependenciesClosedAndreas Müller

Actions
Related to EDIT - bug #10141: Exception (CCE) caused by logging setLevel in phycobankClosedAndreas Müller

Actions
Copied from EDIT - task #9359: Update cdmlib, taxeditor, cdmserver etc. dependenciesClosedAndreas Müller

Actions
Copied to EDIT - task #10055: Updates, upgrades and cleanup 2023NewAndreas Müller

Actions
Copied to EDIT - task #10099: Try to use log4j instead of logback in CDM serverNewAndreas Müller

Actions
Copied to EDIT - bug #10105: Fix logging in TaxEditor after migration to log4j 2NewAndreas Müller

Actions
Actions #1

Updated by Andreas Müller about 2 years ago

  • Copied from task #9359: Update cdmlib, taxeditor, cdmserver etc. dependencies added
Actions #2

Updated by Andreas Müller about 2 years ago

  • Copied to task #10055: Updates, upgrades and cleanup 2023 added
Actions #3

Updated by Andreas Müller about 2 years ago

  • Description updated (diff)
Actions #4

Updated by Andreas Müller about 2 years ago

  • Description updated (diff)
Actions #5

Updated by Andreas Müller about 2 years ago

  • Description updated (diff)
Actions #6

Updated by Andreas Müller about 2 years ago

  • Description updated (diff)
Actions #7

Updated by Andreas Müller about 2 years ago

  • Description updated (diff)
Actions #8

Updated by Andreas Müller about 2 years ago

  • Description updated (diff)
  • Target version changed from Unassigned CDM tickets to Release 5.32
  • % Done changed from 0 to 20
Actions #9

Updated by Andreas Müller about 2 years ago

  • Description updated (diff)
Actions #10

Updated by Andreas Müller about 2 years ago

  • Status changed from New to Resolved
  • % Done changed from 20 to 60

More or less solved.

Open issues:

  • handl setLevel() better (see current workaround in cdmlib-commons LogUtils class; better use markers (see log4j docu) or explicit level loggers (e.g eu.etaxonomy.cdm.trace or generally only "trace", "debug" so these are then base loggers for all trace, debug, info, ... logging => AM: I implemented according methods in LogUtils and adapted existing code (not in tests as they are not time critical); this should be sufficient for now
  • decide if we should remove more log4j.xml files from cdmlib (e.g. by keeping only 1 file in cdmlib-commons which has some default configurations that can be used everywhere) and others
  • logging issue in TaxEditor (see #note-15)
  • clean up imports in java files that still have "import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger" in one line (search in eclipse for the st and replace with line break by recompiling class
  • clean up explicit class parameter in LogManager.getLogger(xxx) call, better use LogManager.getLogger() without parameter as this is easier to copy and still correct

The both latter tasks can be done in one step by deleting the existing line with "private static final Logger logger = LogManager.getLogger(Class.class);" and replace it with "private static final Logger logger = LogManager.getLogger();". This will rearrange the imports. Remaining LogManager.getLogger(xxx) calls, that are not found by the first search (2 imports in one line) can be found by searching for LogManager.getLogger(A, LogManager.getLogger(B, LogManager.getLogger(C ...

Actions #11

Updated by Andreas Müller about 2 years ago

  • Related to task #9205: Remove apache-log4j-extras from TaxEditor dependencies added
Actions #12

Updated by Andreas Müller about 2 years ago

  • Assignee changed from Andreas Müller to Katja Luther

Can you please review and maybe work on the clean up open issues a bit so we get clean code soon.

Actions #13

Updated by Andreas Müller about 2 years ago

  • % Done changed from 60 to 70
Actions #14

Updated by Andreas Müller about 2 years ago

  • Description updated (diff)
Actions #15

Updated by Andreas Müller about 2 years ago

There is still an issue with log4j-slf4j-impl in TaxEditor. For some reason it is not recognized as existing library when I add it to taxeditor.cdmlib pom, manifest.mf and build.properties as I do with other dependencies.
Therefore data logged via slf4j is still logged as NOP and also stacktraces are thrown during build (see log file in jenkins).

Actions #16

Updated by Andreas Müller about 2 years ago

  • Copied to task #10099: Try to use log4j instead of logback in CDM server added
Actions #17

Updated by Andreas Müller about 2 years ago

  • Description updated (diff)
Actions #18

Updated by Andreas Müller about 2 years ago

  • Description updated (diff)
Actions #19

Updated by Andreas Müller about 2 years ago

  • Priority changed from New to Priority14
Actions #20

Updated by Andreas Müller about 2 years ago

  • Copied to bug #10105: Fix logging in TaxEditor after migration to log4j 2 added
Actions #21

Updated by Andreas Müller about 2 years ago

TaxEditor issue moved to new ticket #10105.

Actions #22

Updated by Andreas Müller about 2 years ago

I also had problems installing the correct logging when running cdmlib test in IDE (here tests in cdmlib-services). This should be further investigated.

Actions #23

Updated by Andreas Müller about 2 years ago

  • Description updated (diff)
Actions #24

Updated by Andreas Müller about 2 years ago

Andreas Müller wrote in #note-15:

There is still an issue with log4j-slf4j-impl in TaxEditor. For some reason it is not recognized as existing library when I add it to taxeditor.cdmlib pom, manifest.mf and build.properties as I do with other dependencies.
Therefore data logged via slf4j is still logged as NOP and also stacktraces are thrown during build (see log file in jenkins).

log4j-slf4j-impl is now recognized, same as jcl-over-slf4j, but the problem still exists

Actions #26

Updated by Andreas Müller about 2 years ago

Also we may want to handle jboss logging via jsl4j, this is not yet added.

Actions #27

Updated by Andreas Müller about 2 years ago

  • Status changed from Resolved to Closed
  • Assignee changed from Katja Luther to Andreas Müller
  • % Done changed from 70 to 100

This should be fixed. Open issues moved to new tickets.

Actions #28

Updated by Andreas Müller almost 2 years ago

  • Related to bug #10141: Exception (CCE) caused by logging setLevel in phycobank added
Actions

Also available in: Atom PDF