[ 
https://issues.apache.org/jira/browse/MNG-7532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17742287#comment-17742287
 ] 

ASF GitHub Bot commented on MNG-7532:
-------------------------------------

rmannibucau commented on PR #793:
URL: https://github.com/apache/maven/pull/793#issuecomment-1631926675

   @gnodet let's ignore a second the classloading errors and take a simple 
functional case: you want logger X to be logged particularly and the app knows 
the provider it uses so can configure it directly - this is a common case as we 
discussed on slack. I'll use JUL binding for the example but it is not rare it 
is logback or log4j2 too.
   Do we want to say to users "no, will never work until you implement another 
classloading abstraction to isolate yourself from plugin ecosystem"? Not on my 
side.
   
   Here is a simple mojo showing it:
   
   ```pom.xml
   <dependency>
     <groupId>org.slf4j</groupId>
     <artifactId>slf4j-api</artifactId>
     <version>1.7.36</version>
   </dependency>
   <dependency>
     <groupId>org.slf4j</groupId>
     <artifactId>slf4j-jdk14</artifactId>
     <version>1.7.36</version>
   </dependency>
   ```
   
   ```java
   @Mojo(name = "demo", defaultPhase = NONE)
   public class MyMojo extends AbstractMojo {
       @Override
       public void execute() {
           run();
       }
   
       private void run() {
           final var loggerName = getClass().getName();
           final var logger = Logger.getLogger(loggerName);
           final var delegate = Logger.getLogger("");
           logger.addHandler(new Handler() {
               @Override
               public void publish(final LogRecord record) { // just a hack to 
get console logger but not close it
                   delegate.getHandlers()[0].publish(record);
               }
   
               @Override
               public void flush() {
                   // no-op
               }
   
               @Override
               public void close() throws SecurityException {
                   // no-op
               }
           });
           LoggerFactory.getLogger(loggerName)
                   .info("I am here");
       }
   }
   ```
   
   Indeed you have to assume the logging configuration is not part of the 
execute method but a transitive one - a bit like spring logging system.
   
   Running this mojo we get:
   
   ```
   [INFO] -

> Revert MNG-6931 deprecation since list shows no consensus on that
> -----------------------------------------------------------------
>
>                 Key: MNG-7532
>                 URL: https://issues.apache.org/jira/browse/MNG-7532
>             Project: Maven
>          Issue Type: Task
>            Reporter: Romain Manni-Bucau
>            Priority: Major
>
> There are several threads on the dev list asking for the drop of slf4j and at 
> least keeping a logging abstraction for not internal dev (= core can use 
> slf4j but not mojo/extensions).
> Work is being done to abstract plugin api so let's keep the 
> deprecation/replacement of our Log API in this track and keep it the official 
> way for now.
> one of the multiple refs: 
> https://www.mail-archive.com/dev@maven.apache.org/msg123452.html



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to