Search in sources :

Example 1 with LogFactory

use of org.apache.commons.logging.LogFactory in project nimbus by nimbus-org.

the class NimbusLogFactory method createDefaultLogFactory.

/**
 * デフォルトのLogFactoryを生成する。<p>
 *
 * @return デフォルトのLogFactory
 */
private LogFactory createDefaultLogFactory() throws LogConfigurationException {
    LogFactory factory = null;
    try {
        final String factoryClass = System.getProperty(DEFAULT_FACTORY_PROPERTY);
        if (factoryClass != null) {
            final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            factory = newFactory(factoryClass, classLoader);
        }
    } catch (SecurityException e) {
        factory = null;
    }
    if (factory == null) {
        final String factoryClass = (String) getAttribute(DEFAULT_FACTORY_PROPERTY);
        if (factoryClass != null) {
            final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            factory = newFactory(factoryClass, classLoader);
        }
    }
    if (factory == null) {
        final ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        factory = newFactory(DEFAULT_FACTORY_DEFAULT, classLoader);
    }
    if (factory != null) {
        final String[] names = getAttributeNames();
        for (int i = 0; i < names.length; i++) {
            final String name = names[i];
            factory.setAttribute(name, getAttribute(name));
        }
    }
    return factory;
}
Also used : LogFactory(org.apache.commons.logging.LogFactory)

Example 2 with LogFactory

use of org.apache.commons.logging.LogFactory in project nimbus by nimbus-org.

the class DefaultCommonsLogFactoryService method startService.

/**
 * 開始処理を行う。<p>
 * このメソッドには、以下の実装が行われている。<br>
 * <ol>
 *   <li>super.startService()呼び出し。</li>
 *   <li>Commonsログカテゴリをデフォルトカテゴリとして登録する。</li>
 *   <li>ログ出力フォーマットを{@link DefaultCommonsLogFactoryServiceMBean#DEFAULT_FORMAT}に変更する。</li>
 *   <li>{@link NimbusLogFactory#setCommonsLogFactory(CommonsLogFactory)}に自分自身を設定する。</li>
 * </ol>
 *
 * @exception Exception 開始処理に失敗した場合
 */
public void startService() throws Exception {
    defaultFormat = DefaultCommonsLogFactoryServiceMBean.DEFAULT_FORMAT;
    super.startService();
    // NimbusLogFactoryに登録
    final LogFactory logFactory = LogFactory.getFactory();
    if (logFactory instanceof NimbusLogFactory) {
        ((NimbusLogFactory) logFactory).setCommonsLogFactory(this);
    }
}
Also used : LogFactory(org.apache.commons.logging.LogFactory)

Example 3 with LogFactory

use of org.apache.commons.logging.LogFactory in project nimbus by nimbus-org.

the class DefaultCommonsLogFactoryService method stopService.

/**
 * 停止処理を行う。<p>
 * このメソッドには、以下の実装が行われている。<br>
 * <ol>
 *   <li>super.stopService()呼び出し。</li>
 *   <li>{@link #release()}を呼び出す。</li>
 *   <li>{@link NimbusLogFactory#setCommonsLogFactory(CommonsLogFactory)}にnullを設定する。</li>
 * </ol>
 */
public void stopService() {
    super.stopService();
    release();
    final LogFactory logFactory = LogFactory.getFactory();
    if (logFactory instanceof NimbusLogFactory) {
        ((NimbusLogFactory) logFactory).setCommonsLogFactory(null);
    }
}
Also used : LogFactory(org.apache.commons.logging.LogFactory)

Aggregations

LogFactory (org.apache.commons.logging.LogFactory)3