Java slf4j Logger configureXWikiLogs()

Here you can find the source of configureXWikiLogs()

Description

If running under Maven 3.1+, where slf4j-simple is used as the logging backend, configure the SLF4J simple to have proper logging levels that do not generate too many logs.

License

Open Source License

Declaration

public static void configureXWikiLogs() 

Method Source Code

//package com.java2s;
/*/*from   w  ww  .j a va 2 s . c  om*/
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

public class Main {
    private static final String INFO_LEVEL = "info";
    private static final String WARN_LEVEL = "warn";
    private static final String ERROR_LEVEL = "error";

    /**
     * If running under Maven 3.1+, where slf4j-simple is used as the logging backend, configure the SLF4J simple to
     * have proper logging levels that do not generate too many logs.
     */
    public static void configureXWikiLogs() {
        // Note 1: This line doesn't have always effect, depending on the version of Maven used. It's probably because
        // Maven overwrite this system property.
        // Note 2: With Maven >= 3.1 and <= 3.2.2, calling System.setProperty("org.slf4j.simpleLogger.defaultLogLevel")
        // returns the proper default logging level. However with Maven >= 3.2.3 calling
        // System.setProperty("org.slf4j.simpleLogger.defaultLogLevel") returns null for some reason.
        System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", WARN_LEVEL);

        // Explicitly configure the logging levels for various packages
        System.setProperty("org.slf4j.simpleLogger.log.org", WARN_LEVEL);
        System.setProperty("org.slf4j.simpleLogger.log.org.xwiki", INFO_LEVEL);
        System.setProperty("org.slf4j.simpleLogger.log.hsqldb", WARN_LEVEL);

        // Explicitly ignore warnings about the logback system, since under Maven 3.1+ the logging framework used is
        // slf4j-simple
        System.setProperty("org.slf4j.simpleLogger.log.org.xwiki.logging.logback", ERROR_LEVEL);
    }
}

Related

  1. checkInterrupted(String type, String name, Logger logger)
  2. cleanLoggingMdc()
  3. clearRequestId()
  4. close(final AutoCloseable closeable, final Logger log)
  5. closeQuietly(AutoCloseable toClose, Logger log)
  6. configureXWikiLogs()
  7. countMSCandidates(byte[] byteARR)
  8. countMSCandidates_m2(ArrayList asHexAL)
  9. d d(String fmt, Object... args)