-
Notifications
You must be signed in to change notification settings - Fork 432
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a Log4j2 build listener #192
base: master
Are you sure you want to change the base?
Conversation
This PR adds a Log4j2 build listener as a modern alternative to the obsolete Log4j 1.x listener.
Many thank @ppkarwasz in particular since you found all the places that need to be touched when adding a new dependency. :-) TBH I don't really see any reason why this should be part of the core Ant distribution. Publishing the logger as a separate artifact with a s release cycle separate from Ant itself may be a better idea than adding another (even if optional) dependency to Ant. |
I agree, it does not make sense adding dependency on log4j2. |
@bodewig, I understand the reluctance of adding yet another component with external dependencies to maintain, but I believe this should be a low maintenance listener. If you consider adding it to the Ant project, I can help maintaining it. Otherwise I'll publish it as a separate artifact. @visi: I don't believe we are in the position to impartially decide, which API between Log4j2 and SLF4J is better, :-). SLF4J (even the recent 2.0.0-beta1) does not provide a way to set the location (file name/line number) programmatically, but that could probably be provided as MDC entries. |
Well, it would be nice to avoid dependency on log4j2 if possible since any new CVE would trigger cases like "Ant is using vulnerable log4j" |
This would be just a marketing problem: Log4j2 Core's vulnerabilities never affected the Log4j2 API as well as Logback's vulnerabilities never affected SLF4J. In the case of a new CVE against Log4j2 Core, some users will inquire if it affects Ant anyway (as they did for Log4Shell). In the panic that followed last December's events probably wondered if their old HP calculator was affected. :-) This listener does not depend on Log4j Core. The |
@vlsi What a pointless comment. ANY software can have a CVE. For the record, the Log4j 2 API has never had any CVE's reported against it. From a functionality point of view it is exactly the same as using SLF4J except it has more features. What you are doing is equivalent to saying "Don't use SLF4J because Logback has had CVE's reported against it:. TBH we've considered renaming the Log4j API to something like LA4J (Logging API for Java) or JLA (Java Logging API) just to avoid arguments like yours. But we figure most people with average intelligence will understand if they simply read the documentation. Perhaps we will make a new web site for JLA and the download will just be log4j-api. All that said, I am not weighing on on what should be done with Piotr's contribution. That is up to the Ant PMC to decide. |
I'd say the same thing about an SLF4J based logger implementation. My reluctance to adding new dependencies for things that could be add-ons - maybe just a separate antlib under the umbrella of the Ant project - rather than Ant's core has nothing to do with the dependency being log4j 2.x at all. If we add something the existing dev team is not really interested in - otherwise the logger would exist already - maintaining it becomes a chore that either requires somebody of the dev team has to take care of things they are not really familiar with or relies on somebody external taking over maintenance. Here I feel it would be easier if the artifact was provided by somebody who cares for it. I do hear the "this is a low-maintenance contribution" argument and am not saying NO here, just voicing my opinion. We are maintaining things we accepted more than twentytwo years ago ( |
+1
Well, at least slf4j allows plugging several implementations, so if slf4j is ever added, then users could add whatever logging impl they want via the relevant slf4j-.. bridge.
Well, I could easily imagine how users might want to make the logging level to be configurable. Then, the contribution does not clarify the intended use case. Is it supposed to be used for machine integration? (e.g. a CI server parsing log output) If so, why the default Ant's BuildListeners are not enough? This does not look like a low-maintenance contribution to me 🤷♂️ . Replacing log4j2 with slf4j would not answer "what are the use-cases" questions. It is more like low-unmaintenance contribution. |
@bodewig, I perfectly understand the problem, since the Apache Logging project has the same problem with components nobody has been using for years. As Ralph said, it is to the Ant PMC to decide, if you are interested in this contribution.
@vlsi, you perfectly know that the Log4j2 API has also several implementations (cf. API separation).
If such a need occurs I can modify the listener implementation to log a custom
I plan to use this listener at work to store the build logs in a structured way. |
This PR adds a Log4j2 build listener as a modern alternative to the obsolete Log4j 1.x listener.
The Log4j2 listener differs in some choices from the Log4j counterpart. Most notably:
project_name.target_name.task_name
,className
property of the location info (%C
in the pattern layout of Log4j2 Core),%F
and%L
),VERBOSE
is not mapped toDEBUG
, but a custom level is used.The Log4j2 listener can be used as
BuildLogger
, but the level change feature works only if the underlying Log4j2 API implementation is Log4j2 Core.