Hello, I recently got into a problem with my custom plugin. I want to filter out some loggers, only for my plugin execution and I realized this is not possible at the moment. I found out this issue which states exactly the same:
https://issues.apache.org/jira/browse/MNG-5916 The bottleneck for me seems to be the slf4j. SLF4J does not allow you to change at runtime the log levels, as stated here: http://stackoverflow.com/questions/14544991/how-to-configure-slf4j-simple I actually tried putting this in my Mojo: System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "WARN"); but it had no effect because the logger had already been created. If, on the other hand, they did allow the runtime switch of the log levels then we could have a method (for example reconfigure()) in the AbstractMojo's log object, like this: @Override public void execute() throws MojoExecutionException, MojoFailureException { Map<String, String> config = new HashMap<>(); config.put("org.slf4j.simpleLogger.defaultLogLevel", "WARN"); getLog().reconfigure(config); } and so each Mojo could reconfigure the log before it's own execution. This is very rough, but I hope you get it. I'm also far from the idea to switch the log level API, but is there any particular reason we're sticking with SLF4J's SimpleLogger? I know Log4J2 and Logback provide the ability to change the log levels at runtime. And I also don't think performance-wise they are a lot worse than SLF4J (considering the amount of log a typical maven execution produces). I would be interested to hear your opinion. -- Regards, Petar! Karlovo, Bulgaria. --- Public PGP Key at: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x19658550C3110611 Key Fingerprint: A369 A7EE 61BC 93A3 CDFF 55A5 1965 8550 C311 0611
