Java 类org.slf4j.helpers.Util 实例源码

项目:springboot-shiro-cas-mybatis    文件:CasLoggerFactory.java   
private Set<Class<? extends ILoggerFactory>> lookUpConfiguredLoggerFactory() {
    final Set<Class<? extends ILoggerFactory>> loggerFactories = new HashSet<>();

    final String configuredLoggerFactory = System.getProperty(ENVIRONMENT_VAR_LOGGER_FACTORY);
    if (StringUtils.isNotBlank(configuredLoggerFactory)) {
        Util.report("Instructed logger factory to use is " + configuredLoggerFactory);
        try {
            final Class clazz = Class.forName(configuredLoggerFactory);
            loggerFactories.add(clazz);
        } catch (final Exception e) {
            Util.report("Could not locate the provided logger factory: " + configuredLoggerFactory + ". Error: " + e.getMessage());
        }
    }

    return loggerFactories;
}
项目:cas-server-4.2.1    文件:CasLoggerFactory.java   
private Set<Class<? extends ILoggerFactory>> lookUpConfiguredLoggerFactory() {
    final Set<Class<? extends ILoggerFactory>> loggerFactories = new HashSet<>();

    final String configuredLoggerFactory = System.getProperty(ENVIRONMENT_VAR_LOGGER_FACTORY);
    if (StringUtils.isNotBlank(configuredLoggerFactory)) {
        Util.report("Instructed logger factory to use is " + configuredLoggerFactory);
        try {
            final Class clazz = Class.forName(configuredLoggerFactory);
            loggerFactories.add(clazz);
        } catch (final Exception e) {
            Util.report("Could not locate the provided logger factory: " + configuredLoggerFactory + ". Error: " + e.getMessage());
        }
    }

    return loggerFactories;
}
项目:HttpSessionReplacer    文件:SimpleLogger.java   
private static PrintStream computeTargetStream(String logFile) {
  if ("System.err".equalsIgnoreCase(logFile))
    return System.err; // NOSONAR
  else if ("System.out".equalsIgnoreCase(logFile)) {
    return System.out; // NOSONAR
  } else {
    try {
      FileOutputStream fos = new FileOutputStream(logFile);
      PrintStream printStream = new PrintStream(fos);
      return printStream;
    } catch (FileNotFoundException e) {
      Util.report("Could not open [" + logFile + "]. Defaulting to System.err", e);
      return System.err; // NOSONAR
    }
  }
}
项目:konker-platform    文件:KonkerStaticLoggerBinder.java   
void init() {
    try {
        try {
            (new KonkerContextInitializer(this.defaultLoggerContext)).autoConfig();
        } catch (JoranException var2) {
            Util.report("Failed to auto configure default logger context", var2);
        }

        if(!StatusUtil.contextHasStatusListener(this.defaultLoggerContext)) {
            StatusPrinter.printInCaseOfErrorsOrWarnings(this.defaultLoggerContext);
        }

        this.contextSelectorBinder.init(this.defaultLoggerContext, KEY);
        this.initialized = true;
    } catch (Throwable var3) {
        Util.report("Failed to instantiate [" + LoggerContext.class.getName() + "]", var3);
    }

}
项目:konker-platform    文件:KonkerLoggerFactory.java   
private static final void fixSubstitutedLoggers() {
    List loggers = TEMP_FACTORY.getLoggers();
    if(!loggers.isEmpty()) {
        Util.report("The following set of substitute loggers may have been accessed");
        Util.report("during the initialization phase. Logging calls during this");
        Util.report("phase were not honored. However, subsequent logging calls to these");
        Util.report("loggers will work as normally expected.");
        Util.report("See also http://www.slf4j.org/codes.html#substituteLogger");
        Iterator i$ = loggers.iterator();

        while(i$.hasNext()) {
            SubstituteLogger subLogger = (SubstituteLogger)i$.next();
            subLogger.setDelegate(getKonkerLogger(subLogger.getName()));
            Util.report(subLogger.getName());
        }

        TEMP_FACTORY.clear();
    }
}
项目:konker-platform    文件:KonkerLoggerFactory.java   
private static final void versionSanityCheck() {
    try {
        String e = StaticLoggerBinder.REQUESTED_API_VERSION;
        boolean match = false;
        String[] arr$ = API_COMPATIBILITY_LIST;
        int len$ = arr$.length;

        for(int i$ = 0; i$ < len$; ++i$) {
            String aAPI_COMPATIBILITY_LIST = arr$[i$];
            if(e.startsWith(aAPI_COMPATIBILITY_LIST)) {
                match = true;
            }
        }

        if(!match) {
            Util.report("The requested version " + e + " by your slf4j binding is not compatible with " + Arrays.asList(API_COMPATIBILITY_LIST).toString());
            Util.report("See http://www.slf4j.org/codes.html#version_mismatch for further details.");
        }
    } catch (NoSuchFieldError var6) {
        ;
    } catch (Throwable var7) {
        Util.report("Unexpected problem occured during version sanity check", var7);
    }

}
项目:konker-platform    文件:KonkerLoggerFactory.java   
static Set<URL> findPossibleStaticLoggerBinderPathSet() {
    LinkedHashSet staticLoggerBinderPathSet = new LinkedHashSet();

    try {
        ClassLoader ioe = LoggerFactory.class.getClassLoader();
        Enumeration paths;
        if(ioe == null) {
            paths = ClassLoader.getSystemResources(STATIC_LOGGER_BINDER_PATH);
        } else {
            paths = ioe.getResources(STATIC_LOGGER_BINDER_PATH);
        }

        while(paths.hasMoreElements()) {
            URL path = (URL)paths.nextElement();
            staticLoggerBinderPathSet.add(path);
        }
    } catch (IOException var4) {
        Util.report("Error getting resources from path", var4);
    }

    return staticLoggerBinderPathSet;
}
项目:konker-platform    文件:KonkerLoggerFactory.java   
private static void reportMultipleBindingAmbiguity(Set<URL> staticLoggerBinderPathSet) {
    if(!isAndroid()) {
        if(isAmbiguousStaticLoggerBinderPathSet(staticLoggerBinderPathSet)) {
            Util.report("Class path contains multiple SLF4J bindings.");
            Iterator i$ = staticLoggerBinderPathSet.iterator();

            while(i$.hasNext()) {
                URL path = (URL)i$.next();
                Util.report("Found binding in [" + path + "]");
            }

            Util.report("See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.");
        }

    }
}
项目:osgiaas    文件:LogServiceForwardingLogger.java   
static void init() {
    INITIALIZED = true;
    loadProperties();

    String defaultLogLevelString = getStringProperty( DEFAULT_LOG_LEVEL_KEY, null );
    if ( defaultLogLevelString != null )
        DEFAULT_LOG_LEVEL = stringToLevel( defaultLogLevelString );

    SHOW_LOG_NAME = getBooleanProperty( SHOW_LOG_NAME_KEY, SHOW_LOG_NAME );
    SHOW_SHORT_LOG_NAME = getBooleanProperty( SHOW_SHORT_LOG_NAME_KEY, SHOW_SHORT_LOG_NAME );
    SHOW_DATE_TIME = getBooleanProperty( SHOW_DATE_TIME_KEY, SHOW_DATE_TIME );
    SHOW_THREAD_NAME = getBooleanProperty( SHOW_THREAD_NAME_KEY, SHOW_THREAD_NAME );
    DATE_TIME_FORMAT_STR = getStringProperty( DATE_TIME_FORMAT_KEY, DATE_TIME_FORMAT_STR );
    LEVEL_IN_BRACKETS = getBooleanProperty( LEVEL_IN_BRACKETS_KEY, LEVEL_IN_BRACKETS );
    WARN_LEVEL_STRING = getStringProperty( WARN_LEVEL_STRING_KEY, WARN_LEVEL_STRING );

    if ( DATE_TIME_FORMAT_STR != null ) {
        try {
            DATE_FORMATTER = new SimpleDateFormat( DATE_TIME_FORMAT_STR );
        } catch ( IllegalArgumentException e ) {
            Util.report( "Bad date format in " + CONFIGURATION_FILE + "; will output relative time", e );
        }
    }
}
项目:osgiaas    文件:LogServiceForwardingLogger.java   
private static PrintStream computeTargetStream( String logFile ) {
    if ( "System.err".equalsIgnoreCase( logFile ) )
        return System.err;
    else if ( "System.out".equalsIgnoreCase( logFile ) ) {
        return System.out;
    } else {
        try {
            FileOutputStream fos = new FileOutputStream( logFile );
            PrintStream printStream = new PrintStream( fos );
            return printStream;
        } catch ( FileNotFoundException e ) {
            Util.report( "Could not open [" + logFile + "]. Defaulting to System.err", e );
            return System.err;
        }
    }
}
项目:bartleby    文件:LoggerFactory.java   
private final static void fixSubstitutedLoggers() {
    List<SubstituteLogger> loggers = TEMP_FACTORY.getLoggers();

    if (loggers.isEmpty()) {
        return;
    }

    Util.report("The following set of substitute loggers may have been accessed");
    Util.report("during the initialization phase. Logging calls during this");
    Util.report("phase were not honored. However, subsequent logging calls to these");
    Util.report("loggers will work as normally expected.");
    Util.report("See also " + SUBSTITUTE_LOGGER_URL);
    for (SubstituteLogger subLogger : loggers) {
        subLogger.setDelegate(getLogger(subLogger.getName()));
        Util.report(subLogger.getName());
    }

    TEMP_FACTORY.clear();
}
项目:bartleby    文件:LoggerFactory.java   
private final static void versionSanityCheck() {
    try {
        String requested = StaticLoggerBinder.REQUESTED_API_VERSION;

        boolean match = false;
        for (int i = 0; i < API_COMPATIBILITY_LIST.length; i++) {
            if (requested.startsWith(API_COMPATIBILITY_LIST[i])) {
                match = true;
            }
        }
        if (!match) {
            Util.report("The requested version " + requested + " by your slf4j binding is not compatible with "
                            + Arrays.asList(API_COMPATIBILITY_LIST).toString());
            Util.report("See " + VERSION_MISMATCH + " for further details.");
        }
    } catch (java.lang.NoSuchFieldError nsfe) {
        // given our large user base and SLF4J's commitment to backward
        // compatibility, we cannot cry here. Only for implementations
        // which willingly declare a REQUESTED_API_VERSION field do we
        // emit compatibility warnings.
    } catch (Throwable e) {
        // we should never reach here
        Util.report("Unexpected problem occured during version sanity check", e);
    }
}
项目:bartleby    文件:LoggerFactory.java   
private static Set<URL> findPossibleStaticLoggerBinderPathSet() {
    // use Set instead of list in order to deal with bug #138
    // LinkedHashSet appropriate here because it preserves insertion order during iteration
    Set<URL> staticLoggerBinderPathSet = new LinkedHashSet<URL>();
    try {
        ClassLoader loggerFactoryClassLoader = LoggerFactory.class.getClassLoader();
        Enumeration<URL> paths;
        if (loggerFactoryClassLoader == null) {
            paths = ClassLoader.getSystemResources(STATIC_LOGGER_BINDER_PATH);
        } else {
            paths = loggerFactoryClassLoader.getResources(STATIC_LOGGER_BINDER_PATH);
        }
        while (paths.hasMoreElements()) {
            URL path = (URL) paths.nextElement();
            staticLoggerBinderPathSet.add(path);
        }
    } catch (IOException ioe) {
        Util.report("Error getting resources from path", ioe);
    }
    return staticLoggerBinderPathSet;
}
项目:bartleby    文件:SimpleLogger.java   
private static PrintStream computeTargetStream(String logFile) {
    if ("System.err".equalsIgnoreCase(logFile))
        return System.err;
    else if ("System.out".equalsIgnoreCase(logFile)) {
        return System.out;
    } else {
        try {
            FileOutputStream fos = new FileOutputStream(logFile);
            PrintStream printStream = new PrintStream(fos);
            return printStream;
        } catch (FileNotFoundException e) {
            Util.report("Could not open [" + logFile + "]. Defaulting to System.err", e);
            return System.err;
        }
    }
}
项目:bartleby    文件:StaticLoggerBinder.java   
/**
 * Package access for testing purposes.
 */
void init() {
  try {
    try {
      new ContextInitializer(defaultLoggerContext).autoConfig();
    } catch (JoranException je) {
      Util.report("Failed to auto configure default logger context", je);
    }
    // logback-292
    if(!StatusUtil.contextHasStatusListener(defaultLoggerContext)) {
      StatusPrinter.printInCaseOfErrorsOrWarnings(defaultLoggerContext);
    }
    contextSelectorBinder.init(defaultLoggerContext, KEY);
    initialized = true;
  } catch (Throwable t) {
    // we should never get here
    Util.report("Failed to instantiate [" + LoggerContext.class.getName()
        + "]", t);
  }
}
项目:JDA    文件:SimpleLogger.java   
private static PrintStream computeTargetStream(String logFile) {
    if ("System.err".equalsIgnoreCase(logFile))
        return System.err;
    else if ("System.out".equalsIgnoreCase(logFile)) {
        return System.out;
    } else {
        try {
            FileOutputStream fos = new FileOutputStream(logFile);
            PrintStream printStream = new PrintStream(fos);
            return printStream;
        } catch (FileNotFoundException e) {
            Util.report("Could not open [" + logFile + "]. Defaulting to System.err", e);
            return System.err;
        }
    }
}
项目:juli-to-slf4j    文件:LoggerFactory.java   
private final static void fixSubstitutedLoggers() {
    List<SubstituteLogger> loggers = TEMP_FACTORY.getLoggers();

    if (loggers.isEmpty()) {
        return;
    }

    Util.report("The following set of substitute loggers may have been accessed");
    Util.report("during the initialization phase. Logging calls during this");
    Util.report("phase were not honored. However, subsequent logging calls to these");
    Util.report("loggers will work as normally expected.");
    Util.report("See also " + SUBSTITUTE_LOGGER_URL);
    for (SubstituteLogger subLogger : loggers) {
        subLogger.setDelegate(getLogger(subLogger.getName()));
        Util.report(subLogger.getName());
    }

    TEMP_FACTORY.clear();
}
项目:juli-to-slf4j    文件:LoggerFactory.java   
private final static void versionSanityCheck() {
    try {
        String requested = requestedApiVersion();

        boolean match = false;
        for (String element : API_COMPATIBILITY_LIST) {
            if (requested.startsWith(element)) {
                match = true;
            }
        }
        if (!match) {
            Util.report("The requested version " + requested + " by your slf4j binding is not compatible with "
                    + Arrays.asList(API_COMPATIBILITY_LIST).toString());
            Util.report("See " + VERSION_MISMATCH + " for further details.");
        }
    } catch (java.lang.NoSuchFieldError nsfe) {
        // given our large user base and SLF4J's commitment to backward
        // compatibility, we cannot cry here. Only for implementations
        // which willingly declare a REQUESTED_API_VERSION field do we
        // emit compatibility warnings.
    } catch (Throwable e) {
        // we should never reach here
        Util.report("Unexpected problem occured during version sanity check", e);
    }
}
项目:red5-mobileconsole    文件:StaticLoggerBinder.java   
/**
 * Package access for testing purposes.
 */
void init() {
    try {
        try {
            new ContextInitializer(defaultLoggerContext).autoConfig();
        } catch (JoranException je) {
            Util.report("Failed to auto configure default logger context", je);
        }
        StatusPrinter.printInCaseOfErrorsOrWarnings(defaultLoggerContext);
        contextSelectorBinder.init(defaultLoggerContext, KEY);
        initialized = true;
    } catch (Throwable t) {
        // we should never get here
        Util.report("Failed to instantiate [" + LoggerContext.class.getName() + "]", t);
    }
}
项目:springboot-shiro-cas-mybatis    文件:CasLoggerFactoryTests.java   
@BeforeClass
public static void beforeClass() throws IOException {
    if (LOG_FILE.exists()) {
        Util.report("Initializing log file " + LOG_FILE.getCanonicalPath());
        FileUtils.write(LOG_FILE, "", false);
    }
}
项目:springboot-shiro-cas-mybatis    文件:CasLoggerFactory.java   
/**
 * Instantiates a new Cas logger factory.
 * Configures the reflection scanning engine to be prepared to scan <code>org.slf4j.impl</code>
 * in order to find other available factories.
 */
public CasLoggerFactory() {
    this.loggerMap = new ConcurrentHashMap<>();
    final Collection<URL> set = ClasspathHelper.forPackage(PACKAGE_TO_SCAN);
    final Reflections reflections = new Reflections(new ConfigurationBuilder().addUrls(set).setScanners(new SubTypesScanner()));

    final Set<Class<? extends ILoggerFactory>> subTypesOf = reflections.getSubTypesOf(ILoggerFactory.class);
    subTypesOf.remove(this.getClass());

    if (subTypesOf.size() > 1) {
        Util.report("Multiple ILoggerFactory bindings are found on the classpath:");
        for (final Class<? extends ILoggerFactory> c : subTypesOf) {
            Util.report("* " + c.getCanonicalName());
        }
    }

    if (subTypesOf.isEmpty()) {
        final RuntimeException e = new RuntimeException("No ILoggerFactory could be found on the classpath."
                + " CAS cannot determine the logging framework."
                + " Examine the project dependencies and ensure that there is one and only one logging framework available.");

        Util.report(e.getMessage(), e);
        throw e;
    }
    this.realLoggerFactoryClass = subTypesOf.iterator().next();
    Util.report("ILoggerFactory to be used for logging is: " + this.realLoggerFactoryClass.getName());
}
项目:springboot-shiro-cas-mybatis    文件:CasLoggerFactoryTests.java   
@BeforeClass
public static void beforeClass() throws IOException {
    if (LOG_FILE.exists()) {
        Util.report("Initializing log file " + LOG_FILE.getCanonicalPath());
        FileUtils.write(LOG_FILE, "", false);
    }
}
项目:cas-server-4.2.1    文件:CasLoggerFactoryTests.java   
@BeforeClass
public static void beforeClass() throws IOException {
    if (LOG_FILE.exists()) {
        Util.report("Initializing log file " + LOG_FILE.getCanonicalPath());
        FileUtils.write(LOG_FILE, "", false);
    }
}
项目:HttpSessionReplacer    文件:SimpleLogger.java   
static synchronized void init() {
  INITIALIZED = true;
  loadProperties();

  String defaultLogLevelString = getStringProperty(DEFAULT_LOG_LEVEL_KEY, null);
  if (defaultLogLevelString != null)
    DEFAULT_LOG_LEVEL = stringToLevel(defaultLogLevelString);

  SHOW_LOG_NAME = getBooleanProperty(SHOW_LOG_NAME_KEY, SHOW_LOG_NAME);
  SHOW_SHORT_LOG_NAME = getBooleanProperty(SHOW_SHORT_LOG_NAME_KEY, SHOW_SHORT_LOG_NAME);
  SHOW_DATE_TIME = getBooleanProperty(SHOW_DATE_TIME_KEY, SHOW_DATE_TIME);
  SHOW_THREAD_NAME = getBooleanProperty(SHOW_THREAD_NAME_KEY, SHOW_THREAD_NAME);
  DATE_TIME_FORMAT_STR = getStringProperty(DATE_TIME_FORMAT_KEY, DATE_TIME_FORMAT_STR);
  LEVEL_IN_BRACKETS = getBooleanProperty(LEVEL_IN_BRACKETS_KEY, LEVEL_IN_BRACKETS);
  WARN_LEVEL_STRING = getStringProperty(WARN_LEVEL_STRING_KEY, WARN_LEVEL_STRING);

  LOG_FILE = getStringProperty(LOG_FILE_KEY, LOG_FILE);
  TARGET_STREAM = computeTargetStream(LOG_FILE);

  if (DATE_TIME_FORMAT_STR != null) {
    try {
      DATE_FORMATTER = new SimpleDateFormat(DATE_TIME_FORMAT_STR);
    } catch (IllegalArgumentException e) {
      Util.report("Bad date format in " + CONFIGURATION_FILE + "; will output relative time", e);
    }
  }
}
项目:konker-platform    文件:KonkerLoggerFactory.java   
private static final void bind() {
    String msg;
    try {
        Set e = findPossibleStaticLoggerBinderPathSet();
        reportMultipleBindingAmbiguity(e);
        StaticLoggerBinder.getSingleton();
        INITIALIZATION_STATE = 3;
        reportActualBinding(e);
        fixSubstitutedLoggers();
    } catch (NoClassDefFoundError var2) {
        msg = var2.getMessage();
        if(!messageContainsOrgSlf4jImplStaticLoggerBinder(msg)) {
            failedBinding(var2);
            throw var2;
        }

        INITIALIZATION_STATE = 4;
        Util.report("Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".");
        Util.report("Defaulting to no-operation (NOP) logger implementation");
        Util.report("See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.");
    } catch (NoSuchMethodError var3) {
        msg = var3.getMessage();
        if(msg != null && msg.contains("org.slf4j.impl.StaticLoggerBinder.getSingleton()")) {
            INITIALIZATION_STATE = 2;
            Util.report("slf4j-api 1.6.x (or later) is incompatible with this binding.");
            Util.report("Your binding is version 1.5.5 or earlier.");
            Util.report("Upgrade your binding to version 1.6.x.");
        }

        throw var3;
    } catch (Exception var4) {
        failedBinding(var4);
        throw new IllegalStateException("Unexpected initialization failure", var4);
    }

}
项目:konker-platform    文件:KonkerLoggerFactory.java   
public static KonkerLogger getLogger(Class<?> clazz) {
    KonkerLogger logger = getKonkerLogger(clazz.getName());
    if(DETECT_LOGGER_NAME_MISMATCH) {
        Class autoComputedCallingClass = Util.getCallingClass();
        if(autoComputedCallingClass != null && nonMatchingClasses(clazz, autoComputedCallingClass)) {
            Util.report(String.format("Detected logger name mismatch. Given name: \"%s\"; computed name: \"%s\".", new Object[]{logger.getName(), autoComputedCallingClass.getName()}));
            Util.report("See http://www.slf4j.org/codes.html#loggerNameMismatch for an explanation");
        }
    }

    return logger;
}
项目:cas4.1.9    文件:CasLoggerFactory.java   
/**
 * Instantiates a new Cas logger factory.
 * Configures the reflection scanning engine to be prepared to scan <code>org.slf4j.impl</code>
 * in order to find other available factories.
 */
public CasLoggerFactory() {
    this.loggerMap = new ConcurrentHashMap<>();
    final Collection<URL> set = ClasspathHelper.forPackage(PACKAGE_TO_SCAN);
    final Reflections reflections = new Reflections(new ConfigurationBuilder().addUrls(set).setScanners(new SubTypesScanner()));

    final Set<Class<? extends ILoggerFactory>> subTypesOf = reflections.getSubTypesOf(ILoggerFactory.class);
    subTypesOf.remove(this.getClass());

    if (subTypesOf.size() > 1) {
        Util.report("Multiple ILoggerFactory bindings are found on the classpath:");
        for (final Class<? extends ILoggerFactory> c : subTypesOf) {
            Util.report("* " + c.getCanonicalName());
        }
    }

    if (subTypesOf.isEmpty()) {
        final RuntimeException e = new RuntimeException("No ILoggerFactory could be found on the classpath."
                + " CAS cannot determine the logging framework."
                + " Examine the project dependencies and ensure that there is one and only one logging framework available.");

        Util.report(e.getMessage(), e);
        throw e;
    }
    this.realLoggerFactoryClass = subTypesOf.iterator().next();
    Util.report("ILoggerFactory to be used for logging is: " + this.realLoggerFactoryClass.getName());
}
项目:cas4.1.9    文件:CasLoggerFactoryTests.java   
@BeforeClass
public static void beforeClass() throws IOException {
    if (LOG_FILE.exists()) {
        Util.report("Initializing log file " + LOG_FILE.getCanonicalPath());
        FileUtils.write(LOG_FILE, "", false);
    }
}
项目:bartleby    文件:LoggerFactory.java   
/**
 * Prints a warning message on the console if multiple bindings were found on the class path.
 * No reporting is done otherwise.
 *
 */
private static void reportMultipleBindingAmbiguity(Set<URL> staticLoggerBinderPathSet) {
    if (isAmbiguousStaticLoggerBinderPathSet(staticLoggerBinderPathSet)) {
        Util.report("Class path contains multiple SLF4J bindings.");
        Iterator<URL> iterator = staticLoggerBinderPathSet.iterator();
        while (iterator.hasNext()) {
            URL path = (URL) iterator.next();
            Util.report("Found binding in [" + path + "]");
        }
        Util.report("See " + MULTIPLE_BINDINGS_URL + " for an explanation.");
    }
}
项目:bartleby    文件:StaticLoggerBinder.java   
private StaticLoggerBinder() {
    loggerFactory = new Log4jLoggerFactory();
    try {
        @SuppressWarnings("unused")
        Level level = Level.TRACE;
    } catch (NoSuchFieldError nsfe) {
        Util.report("This version of SLF4J requires log4j version 1.2.12 or later. See also http://www.slf4j.org/codes.html#log4j_version");
    }
}
项目:bartleby    文件:SimpleLogger.java   
static void init() {
    INITIALIZED = true;
    loadProperties();

    String defaultLogLevelString = getStringProperty(DEFAULT_LOG_LEVEL_KEY, null);
    if (defaultLogLevelString != null)
        DEFAULT_LOG_LEVEL = stringToLevel(defaultLogLevelString);

    SHOW_LOG_NAME = getBooleanProperty(SHOW_LOG_NAME_KEY, SHOW_LOG_NAME);
    SHOW_SHORT_LOG_NAME = getBooleanProperty(SHOW_SHORT_LOG_NAME_KEY, SHOW_SHORT_LOG_NAME);
    SHOW_DATE_TIME = getBooleanProperty(SHOW_DATE_TIME_KEY, SHOW_DATE_TIME);
    SHOW_THREAD_NAME = getBooleanProperty(SHOW_THREAD_NAME_KEY, SHOW_THREAD_NAME);
    DATE_TIME_FORMAT_STR = getStringProperty(DATE_TIME_FORMAT_KEY, DATE_TIME_FORMAT_STR);
    LEVEL_IN_BRACKETS = getBooleanProperty(LEVEL_IN_BRACKETS_KEY, LEVEL_IN_BRACKETS);
    WARN_LEVEL_STRING = getStringProperty(WARN_LEVEL_STRING_KEY, WARN_LEVEL_STRING);

    LOG_FILE = getStringProperty(LOG_FILE_KEY, LOG_FILE);
    TARGET_STREAM = computeTargetStream(LOG_FILE);

    if (DATE_TIME_FORMAT_STR != null) {
        try {
            DATE_FORMATTER = new SimpleDateFormat(DATE_TIME_FORMAT_STR);
        } catch (IllegalArgumentException e) {
            Util.report("Bad date format in " + CONFIGURATION_FILE + "; will output relative time", e);
        }
    }
}
项目:JDA    文件:SimpleLogger.java   
static void init() {
    INITIALIZED = true;
    loadProperties();

    String defaultLogLevelString = getStringProperty(DEFAULT_LOG_LEVEL_KEY, null);
    if (defaultLogLevelString != null)
        DEFAULT_LOG_LEVEL = stringToLevel(defaultLogLevelString);

    SHOW_LOG_NAME = getBooleanProperty(SHOW_LOG_NAME_KEY, SHOW_LOG_NAME);
    SHOW_SHORT_LOG_NAME = getBooleanProperty(SHOW_SHORT_LOG_NAME_KEY, SHOW_SHORT_LOG_NAME);
    SHOW_DATE_TIME = getBooleanProperty(SHOW_DATE_TIME_KEY, SHOW_DATE_TIME);
    SHOW_THREAD_NAME = getBooleanProperty(SHOW_THREAD_NAME_KEY, SHOW_THREAD_NAME);
    DATE_TIME_FORMAT_STR = getStringProperty(DATE_TIME_FORMAT_KEY, DATE_TIME_FORMAT_STR);
    LEVEL_IN_BRACKETS = getBooleanProperty(LEVEL_IN_BRACKETS_KEY, LEVEL_IN_BRACKETS);
    WARN_LEVEL_STRING = getStringProperty(WARN_LEVEL_STRING_KEY, WARN_LEVEL_STRING);

    LOG_FILE = getStringProperty(LOG_FILE_KEY, LOG_FILE);
    TARGET_STREAM = computeTargetStream(LOG_FILE);

    if (DATE_TIME_FORMAT_STR != null) {
        try {
            DATE_FORMATTER = new SimpleDateFormat(DATE_TIME_FORMAT_STR);
        } catch (IllegalArgumentException e) {
            Util.report("Bad date format in " + CONFIGURATION_FILE + "; will output relative time", e);
        }
    }
}
项目:juli-to-slf4j    文件:LoggerFactory.java   
/**
 * Our customized implementation here favors the
 * {@link Thread#getContextClassLoader()} (typically the Catalina class
 * loader) over the class loader that has loaded this {@code LoggerFactory}
 * (typically the System class loader).
 *
 * @return a newly created set of (ordered) URLs for candidate
 *         {@code org.slf4j.impl.StaticLoggerBinder} classes.
 */
private static Set<URL> findPossibleStaticLoggerBinderPathSet() {
    if (org.apache.juli.logging.impl.SLF4JDelegatingLog.diagnostics <= DEBUG_INT) {
        Util.report("LoggerFactory.findPossibleStaticLoggerBinderPathSet()");
    }
    // use Set instead of list in order to deal with bug #138
    // LinkedHashSet appropriate here because it preserves insertion order
    // during iteration
    Set<URL> staticLoggerBinderPathSet = new LinkedHashSet<URL>();
    try {
        ClassLoader classLoader = currentThread().getContextClassLoader();
        if (org.apache.juli.logging.impl.SLF4JDelegatingLog.diagnostics <= DEBUG_INT) {
            report("LoggerFactory.findPossibleStaticLoggerBinderPathSet()" + " currentThread.contextClassLoader: "
                    + classLoader);
        }
        if (classLoader == null) {
            classLoader = LoggerFactory.class.getClassLoader();
        }
        Enumeration<URL> paths;
        if (classLoader == null) {
            paths = ClassLoader.getSystemResources(STATIC_LOGGER_BINDER_PATH);
        } else {
            paths = classLoader.getResources(STATIC_LOGGER_BINDER_PATH);
        }
        while (paths.hasMoreElements()) {
            URL path = paths.nextElement();
            staticLoggerBinderPathSet.add(path);
        }
    } catch (IOException ioe) {
        Util.report("Error getting resources from path", ioe);
    }
    return staticLoggerBinderPathSet;
}
项目:juli-to-slf4j    文件:LoggerFactory.java   
/**
 * Prints a warning message on the console if multiple bindings were found
 * on the class path. No reporting is done otherwise.
 *
 */
private static void reportMultipleBindingAmbiguity(final Set<URL> staticLoggerBinderPathSet) {
    if (isAmbiguousStaticLoggerBinderPathSet(staticLoggerBinderPathSet)) {
        Util.report("Class path contains multiple SLF4J bindings.");
        Iterator<URL> iterator = staticLoggerBinderPathSet.iterator();
        while (iterator.hasNext()) {
            URL path = iterator.next();
            Util.report("Found binding in [" + path + "]");
        }
        Util.report("See " + MULTIPLE_BINDINGS_URL + " for an explanation.");
    }
}
项目:slf4j-libgdx    文件:LibgdxLogger.java   
static void init() {
    INITIALIZED = true;
    loadProperties();

    String defaultLogLevelString = getStringProperty(DEFAULT_LOG_LEVEL_KEY,
            null);
    if (defaultLogLevelString != null)
        DEFAULT_LOG_LEVEL = stringToLevel(defaultLogLevelString);

    SHOW_LOG_NAME = getBooleanProperty(SHOW_LOG_NAME_KEY, SHOW_LOG_NAME);
    SHOW_SHORT_LOG_NAME = getBooleanProperty(SHOW_SHORT_LOG_NAME_KEY,
            SHOW_SHORT_LOG_NAME);
    SHOW_DATE_TIME = getBooleanProperty(SHOW_DATE_TIME_KEY, SHOW_DATE_TIME);
    SHOW_THREAD_NAME = getBooleanProperty(SHOW_THREAD_NAME_KEY,
            SHOW_THREAD_NAME);
    DATE_TIME_FORMAT_STR = getStringProperty(DATE_TIME_FORMAT_KEY,
            DATE_TIME_FORMAT_STR);
    LEVEL_IN_BRACKETS = getBooleanProperty(LEVEL_IN_BRACKETS_KEY,
            LEVEL_IN_BRACKETS);
    WARN_LEVEL_STRING = getStringProperty(WARN_LEVEL_STRING_KEY,
            WARN_LEVEL_STRING);

    LOG_FILE = getStringProperty(LOG_FILE_KEY, LOG_FILE);

    if (DATE_TIME_FORMAT_STR != null) {
        try {
            DATE_FORMATTER = new SimpleDateFormat(DATE_TIME_FORMAT_STR);
        } catch (IllegalArgumentException e) {
            Util.report("Bad date format in " + CONFIGURATION_FILE
                    + "; will output relative time", e);
        }
    }
}
项目:springboot-shiro-cas-mybatis    文件:CasLoggerFactory.java   
/**
 * Instantiates a new Cas logger factory.
 * Configures the reflection scanning engine to be prepared to scan {@code org.slf4j.impl}
 * in order to find other available factories.
 */
public CasLoggerFactory() {
    this.loggerMap = new ConcurrentHashMap<>();

    Set<Class<? extends ILoggerFactory>> loggerFactories = lookUpConfiguredLoggerFactory();
    if (loggerFactories.isEmpty()) {
        loggerFactories = scanContextForLoggerFactories();
    }

    if (loggerFactories.size() > 1) {
        Util.report("Multiple ILoggerFactory bindings are found on the classpath:");
        for (final Class<? extends ILoggerFactory> c : loggerFactories) {
            Util.report("* " + c.getCanonicalName());
        }
        Util.report("This generally indicates a configuration problem which is a result of dependency conflicts.");
        Util.report("If you wish to use a different logging framework, specify the ILoggerFactory binding via -D"
                + ENVIRONMENT_VAR_LOGGER_FACTORY + "=<binding-class> to the runtime environment");
    }

    if (loggerFactories.isEmpty()) {
        final RuntimeException e = new RuntimeException("No ILoggerFactory could be found on the classpath."
                + " CAS cannot determine the logging framework."
                + " Examine the project dependencies and ensure that there is one and only one logging framework available.");

        Util.report(e.getMessage(), e);
        throw e;
    }
    this.realLoggerFactoryClass = null;
    for (final Class<? extends ILoggerFactory> factory : loggerFactories) {
        Util.report("Attempting to locate ILoggerFactory instance from: " + factory.getName());
        if (getLoggerFactoryBeInstantiated(factory) != null) {
            this.realLoggerFactoryClass = factory;
            Util.report("ILoggerFactory to be used for logging is: " + this.realLoggerFactoryClass.getName());
            break;
        } else {
            Util.report("ILoggerFactory [" + factory.getName() + "] could not be used. Trying the next ILoggerFactory...");
        }
    }

    if (this.realLoggerFactoryClass == null) {
        throw new RuntimeException("No ILoggerFactory is available to use. Log configuration is incorrect, "
                        + "or multiple logging frameworks are at conflict with one another on the classpath.");
    }
}
项目:cas-server-4.2.1    文件:CasLoggerFactory.java   
/**
 * Instantiates a new Cas logger factory.
 * Configures the reflection scanning engine to be prepared to scan {@code org.slf4j.impl}
 * in order to find other available factories.
 */
public CasLoggerFactory() {
    this.loggerMap = new ConcurrentHashMap<>();

    Set<Class<? extends ILoggerFactory>> loggerFactories = lookUpConfiguredLoggerFactory();
    if (loggerFactories.isEmpty()) {
        loggerFactories = scanContextForLoggerFactories();
    }

    if (loggerFactories.size() > 1) {
        Util.report("Multiple ILoggerFactory bindings are found on the classpath:");
        for (final Class<? extends ILoggerFactory> c : loggerFactories) {
            Util.report("* " + c.getCanonicalName());
        }
        Util.report("This generally indicates a configuration problem which is a result of dependency conflicts.");
        Util.report("If you wish to use a different logging framework, specify the ILoggerFactory binding via -D"
                + ENVIRONMENT_VAR_LOGGER_FACTORY + "=<binding-class> to the runtime environment");
    }

    if (loggerFactories.isEmpty()) {
        final RuntimeException e = new RuntimeException("No ILoggerFactory could be found on the classpath."
                + " CAS cannot determine the logging framework."
                + " Examine the project dependencies and ensure that there is one and only one logging framework available.");

        Util.report(e.getMessage(), e);
        throw e;
    }
    this.realLoggerFactoryClass = null;
    for (final Class<? extends ILoggerFactory> factory : loggerFactories) {
        Util.report("Attempting to locate ILoggerFactory instance from: " + factory.getName());
        if (getLoggerFactoryBeInstantiated(factory) != null) {
            this.realLoggerFactoryClass = factory;
            Util.report("ILoggerFactory to be used for logging is: " + this.realLoggerFactoryClass.getName());
            break;
        } else {
            Util.report("ILoggerFactory [" + factory.getName() + "] could not be used. Trying the next ILoggerFactory...");
        }
    }

    if (this.realLoggerFactoryClass == null) {
        throw new RuntimeException("No ILoggerFactory is available to use. Log configuration is incorrect, "
                        + "or multiple logging frameworks are at conflict with one another on the classpath.");
    }
}
项目:konker-platform    文件:KonkerLoggerFactory.java   
static void failedBinding(Throwable t) {
    INITIALIZATION_STATE = 2;
    Util.report("Failed to instantiate SLF4J LoggerFactory", t);
}
项目:konker-platform    文件:KonkerLoggerFactory.java   
private static boolean isAndroid() {
    String vendor = Util.safeGetSystemProperty("java.vendor.url");
    return vendor == null?false:vendor.toLowerCase().contains("android");
}
项目:konker-platform    文件:KonkerLoggerFactory.java   
private static void reportActualBinding(Set<URL> staticLoggerBinderPathSet) {
    if(isAmbiguousStaticLoggerBinderPathSet(staticLoggerBinderPathSet)) {
        Util.report("Actual binding is of type [" + StaticLoggerBinder.getSingleton().getLoggerFactoryClassStr() + "]");
    }

}