Search in sources :

Example 1 with Jdk14Logger

use of org.apache.commons.logging.impl.Jdk14Logger in project ACS by ACS-Community.

the class CommonsLoggingFactory method newInstance.

@Override
protected synchronized Log newInstance(String name) throws LogConfigurationException {
    //		System.out.println("CommonsLoggingFactoryForACS#newInstance called for name=" + name);
    // Check which framework is requesting the apache commons logger
    String loggerNameBase = null;
    StackTraceElement[] stackTrace = (new Exception()).getStackTrace();
    for (StackTraceElement stackTraceElement : stackTrace) {
        if (stackTraceElement.getClassName().contains("org.apache.commons.scxml")) {
            loggerNameBase = SCXML_LOGGER_NAME_PREFIX;
            break;
        }
    // TODO: add check for other frameworks that use apache logging commons, once we have those
    }
    // Give up if we did not recognize the client framework
    if (loggerNameBase == null) {
        return super.newInstance(name);
    }
    // Check if we already have a logger for the client framework, and create it if needed.
    Log myLog = loggerMap.get(loggerNameBase);
    if (myLog == null) {
        final String loggerNameBaseFinal = loggerNameBase;
        myLog = new Jdk14Logger(loggerNameBase) {

            @Override
            public Logger getLogger() {
                // to some known framework loggers, in the absence of other specific log configuration.
                return ClientLogManager.getAcsLogManager().getLoggerForCorba(loggerNameBaseFinal, true);
            }
        };
        loggerMap.put(loggerNameBase, myLog);
    }
    return myLog;
}
Also used : Jdk14Logger(org.apache.commons.logging.impl.Jdk14Logger) Log(org.apache.commons.logging.Log) Logger(java.util.logging.Logger) Jdk14Logger(org.apache.commons.logging.impl.Jdk14Logger) LogConfigurationException(org.apache.commons.logging.LogConfigurationException)

Example 2 with Jdk14Logger

use of org.apache.commons.logging.impl.Jdk14Logger in project spring-boot by spring-projects.

the class JavaLoggingSystemTests method init.

@Before
public void init() throws SecurityException, IOException {
    this.defaultLocale = Locale.getDefault();
    Locale.setDefault(Locale.ENGLISH);
    this.logger = new Jdk14Logger(getClass().getName());
}
Also used : Jdk14Logger(org.apache.commons.logging.impl.Jdk14Logger) Before(org.junit.Before)

Aggregations

Jdk14Logger (org.apache.commons.logging.impl.Jdk14Logger)2 Logger (java.util.logging.Logger)1 Log (org.apache.commons.logging.Log)1 LogConfigurationException (org.apache.commons.logging.LogConfigurationException)1 Before (org.junit.Before)1