Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 82510200B21 for ; Fri, 10 Jun 2016 20:26:48 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 80FD0160A38; Fri, 10 Jun 2016 18:26:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id C690B160A15 for ; Fri, 10 Jun 2016 20:26:47 +0200 (CEST) Received: (qmail 3463 invoked by uid 500); 10 Jun 2016 18:26:46 -0000 Mailing-List: contact dev-help@maven.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Maven Developers List" Reply-To: "Maven Developers List" Delivered-To: mailing list dev@maven.apache.org Received: (qmail 3452 invoked by uid 99); 10 Jun 2016 18:26:46 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Jun 2016 18:26:46 +0000 Received: from desktop-2khsk44 (5248749D.cm-4-1b.dynamic.ziggo.nl [82.72.116.157]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id 1C3761A015B for ; Fri, 10 Jun 2016 18:26:45 +0000 (UTC) Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Maven Developers List" Subject: Re: MNG-5916: Allow filtering out certain loggers from within a plugin References: Date: Fri, 10 Jun 2016 20:26:58 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Robert Scholte" Organization: Apache Software Foundation Message-ID: In-Reply-To: User-Agent: Opera Mail/12.17 (Win64) archived-at: Fri, 10 Jun 2016 18:26:48 -0000 Hi Petar, I don't think that it should be the *plugin* who decides what the loglevel should be, but the user. One of my big wishes is to be able to specify for which plugin or goal you want to change the loglevel. For example: mvn verify -X makes *everything* log on debug level. Instead I would to see something like -X install:install, meaning I would see normal (info) logging for all but the install goal of the maven-install-plugin. The problem is that you expect to see debug messages from Maven (and other used libraries) as well, just like it is done right now. Dynamically switching loglevel for these shared core-classes is a challenge, especially in when running with multiple threads! Based on MNG-5916 it states that this is regression, so the problem seems to be a bit different. However I don't like the idea that the plugin controls the loglevels. thanks, Robert On Fri, 10 Jun 2016 14:41:09 +0200, Petar Tahchiev wrote: > 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 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. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org For additional commands, e-mail: dev-help@maven.apache.org