Bug 1351822 - Support maven colorized logging
Summary: Support maven colorized logging
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: maven
Version: 23
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Mikolaj Izdebski
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-07-01 00:44 UTC by Christopher Tubbs
Modified: 2016-08-11 11:23 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-08-11 11:23:22 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
log4j2.xml (463 bytes, application/xml)
2016-07-01 00:44 UTC, Christopher Tubbs
no flags Details
Example m2.conf (430 bytes, text/plain)
2016-07-01 06:21 UTC, Mikolaj Izdebski
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Apache JIRA MNG-5961 0 None None None 2016-07-01 00:44:37 UTC

Description Christopher Tubbs 2016-07-01 00:44:37 UTC
Created attachment 1174774 [details]
log4j2.xml

Description of problem:

Maven 3 added colorized logging support via log4j2. However, the default installation of maven does not add log4j-slf4j (slf4j binding to log4j2) or an appropriate log4j2.xml file for colorized output.

Worse, the way maven loads its dependencies (symlinks in /usr/share/maven/lib/* and /usr/share/maven/lib/ext/*) make it difficult for users to configure colorization without those settings being clobbered by an RPM update (because it's a classpath decision which isn't set in /etc).

The solution is to:
1. create /etc/maven/logging/log4j2.xml (attached)
2. install log4j-slf4j.noarch
3. remove the symlink at /usr/share/maven/lib/slf4j_simple.jar
4. add symlinks (in /usr/share/maven/lib or /usr/share/maven/lib/ext) to each of $(build-classpath log4j/log4j-api log4j/log4j-core log4j/log4j-slf4j-impl slf4j/ext)

Additionally, there's an annoying bug in Maven 3.3.3 which gives a warning when switching to colorized output: https://issues.apache.org/jira/browse/MNG-5961

Version-Release number of selected component (if applicable):

maven-3.3.3-3.fc23.noarch

Comment 1 Mikolaj Izdebski 2016-07-01 06:20:24 UTC
(In reply to Christopher Tubbs from comment #0)
> Maven 3 added colorized logging support via log4j2. However, the default
> installation of maven does not add log4j-slf4j (slf4j binding to log4j2) or
> an appropriate log4j2.xml file for colorized output.

Maven upstream is currently working on adding out-of-the-box colorization in next major release (3.4.0). Maybe you can just wait for it?

> Worse, the way maven loads its dependencies (symlinks in
> /usr/share/maven/lib/* and /usr/share/maven/lib/ext/*) make it difficult for
> users to configure colorization without those settings being clobbered by an
> RPM update (because it's a classpath decision which isn't set in /etc).

There are multiple ways of customizing Maven installation by editing config files, either globally or only for specific users (doesn't even require root access). If you want equivalent of globally adding JARs to lib/ or lib/ext/ then you can simply edit /etc/m2.conf and list arbitrary JARs there. This config file is marked as %config(noreplace), so it won't be updated by RPM. You don't need to remove slf4j-simple.jar - SLF4J warnings about multiple bindings can be avoided by using more advanced Maven class loading tricks, like creating separate class realm "log4j" and making "plexus.core" import classes from it. Example m2.conf is attached. Let me know if you need more information.

> Additionally, there's an annoying bug in Maven 3.3.3 which gives a warning
> when switching to colorized output:
> https://issues.apache.org/jira/browse/MNG-5961

This one I can patch in Fedora.

Comment 2 Mikolaj Izdebski 2016-07-01 06:21:17 UTC
Created attachment 1174813 [details]
Example m2.conf

Comment 3 Christopher Tubbs 2016-07-01 19:23:47 UTC
(In reply to Mikolaj Izdebski from comment #1)
> Maven upstream is currently working on adding out-of-the-box colorization in
> next major release (3.4.0). Maybe you can just wait for it?

Sure can. I didn't see any other open bugs about it. This can certainly wait for 3.4.0. I have patched my own system in the meantime, and that works well enough for me.

(In reply to Mikolaj Izdebski from comment #2)
> Created attachment 1174813 [details]
> Example m2.conf

Thanks, but without removing the slf4j-simple, won't slf4j complain about multiple bindings on the classpath?

Comment 4 Mikolaj Izdebski 2016-07-04 05:26:44 UTC
(In reply to Christopher Tubbs from comment #3)
> Thanks, but without removing the slf4j-simple, won't slf4j complain about
> multiple bindings on the classpath?

No, separate class realm is created specifically to avoid this warning. Classes imported from other realms (log4j) shadow classes from current realm (plexus.core).

Comment 5 Michael Simacek 2016-08-11 11:23:22 UTC
Maven 3.4.0 snapshot available in rawhide (f26) already has out-of-the-box colorized logging. We don't plan to submit the snapshot to stable Fedoras. For those, please use the workaround provided.


Note You need to log in before you can comment on or make changes to this bug.