Example usage for org.apache.commons.logging LogFactory getFactory

List of usage examples for org.apache.commons.logging LogFactory getFactory

Introduction

In this page you can find the example usage for org.apache.commons.logging LogFactory getFactory.

Prototype

@Deprecated
public static LogFactory getFactory() 

Source Link

Document

This method only exists for compatibility with unusual Commons Logging API usage like e.g.

Usage

From source file:org.socraticgrid.presentationservices.SetMessagesTest.java

@Before
public void setUp() {
    LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
            "org.apache.commons.logging.impl.NoOpLog");
    System.out.println("SETMESSAGES - HOST IS: " + server);
}

From source file:org.socraticgrid.presentationservices.SurveyTest.java

@Before
public void setUp() {
    LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
            "org.apache.commons.logging.impl.NoOpLog");
    System.out.println("SURVEY TEST HOST IS: " + server);
}

From source file:org.socraticgrid.presentationservices.ValidateAccountTest.java

@Before
public void setUp() {
    LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
            "org.apache.commons.logging.impl.NoOpLog");
    System.out.println("VALIDATEACCOUNT HOST IS: " + server);
}

From source file:org.usrz.libs.logging.CommonsLoggingInitializer.java

public static void init() {
    if (initialized)
        return;/*from www .  ja  va2  s .  c o  m*/

    synchronized (CommonsLoggingInitializer.class) {
        try {
            final String property = System.getProperty(SYSTEM_PROPERTY);
            if ((property != null) && (!CommonsLoggingBridge.class.getName().equals(property)))
                throw new IllegalStateException(
                        "System property \"" + SYSTEM_PROPERTY + "\" set to \"" + property + "\"");
            System.setProperty(SYSTEM_PROPERTY, CommonsLoggingBridge.class.getName());

            final CommonsLoggingBridge bridge = (CommonsLoggingBridge) LogFactory.getFactory();
            final CommonsLoggingAdapter adapter = (CommonsLoggingAdapter) LogFactory
                    .getLog(JavaLoggingInitializer.class);

            if (bridge == null)
                throw new IllegalStateException("No Commons LogFactory instantiated");
            if (adapter == null)
                throw new IllegalStateException("No Commons Log instantiated");

        } catch (ClassCastException exception) {
            System.err.println("WARNING: Commons Logging not initialized:" + " bridge="
                    + LogFactory.getFactory().getClass().getName() + " adapter="
                    + LogFactory.getLog(JavaLoggingInitializer.class).getClass().getName());
        }

        /* We are initialized */
        initialized = true;
    }
}

From source file:org.xulux.gui.NYXToolkitTest.java

/**
 * Test getting the instance/*from  w ww .ja v a 2 s  .  c  om*/
 */
public void testGetInstance() {
    System.out.println("testGetInstance");
    XuluxContext c = XuluxContext.getInstance();
    // by default it is the swing toolkit that shows up
    // so before getting it, set it to something bogus
    String def = XuluxContext.getGuiDefaults().getDefaultGuiLayer();
    XuluxContext.getGuiDefaults().setDefaultGuiLayer("bogus");
    assertNull(XuluxToolkit.getInstance());
    ((SimpleLog) LogFactory.getLog(XuluxToolkit.class)).setLevel(SimpleLog.LOG_LEVEL_OFF);
    assertNull(XuluxToolkit.getInstance());
    ((SimpleLog) LogFactory.getFactory().getInstance(XuluxToolkit.class)).setLevel(SimpleLog.LOG_LEVEL_WARN);
    XuluxContext.getGuiDefaults().setDefaultGuiLayer(def);
    XuluxToolkit kit = XuluxToolkit.getInstance();
    assertNotNull(kit);
    assertEquals(kit, XuluxToolkit.getInstance());
}

From source file:org.xulux.utils.ClassLoaderUtilsTest.java

/**
 * Test the objectFromClass//from ww w. java  2  s.c  o m
 * and the objectFromClassString
 */
public void testObjectFromClass() throws Exception {
    System.out.println("testObjectFromClass");
    assertEquals(new String(), ClassLoaderUtils.getObjectFromClassString("java.lang.String"));
    assertEquals(new String(), ClassLoaderUtils.getObjectFromClass(String.class));
    assertNull(ClassLoaderUtils.getObjectFromClassString("bogus.class.name"));
    assertNull(ClassLoaderUtils.getObjectFromClass(null, null));
    // Test Logging of classloader failures.
    assertNull(ClassLoaderUtils.getObjectFromClass(PrivateInner.class));
    assertNull(ClassLoaderUtils.getObjectFromClass(ExceptionInner.class));
    assertNull(ClassLoaderUtils.getObjectFromClass(AbstractInner.class));
    assertNull(ClassLoaderUtils.getObjectFromClass(ClassLoaderObject.class));
    assertNull(ClassLoaderUtils.getObjectFromClass(PrivateInnerClassObject.InnerClass.class));
    List list = new ArrayList();
    list.add(null);
    assertEquals(PublicInnerClassObject.class,
            ClassLoaderUtils.getObjectFromClass(PublicInnerClassObject.class, list).getClass());
    ((SimpleLog) LogFactory.getLog(ClassLoaderUtils.class)).setLevel(SimpleLog.LOG_LEVEL_OFF);
    assertEquals(PublicInnerClassObject.class,
            ClassLoaderUtils.getObjectFromClass(PublicInnerClassObject.class, list).getClass());
    ((SimpleLog) LogFactory.getFactory().getInstance(ClassLoaderUtils.class))
            .setLevel(SimpleLog.LOG_LEVEL_WARN);
}

From source file:phex.common.log.NLogger.java

/**
 * Returns a log instance./*from   w  w w.  j  a  v a 2s .com*/
 * @param clazz
 * @return a log instance.
 */
public static Log getLogInstance(String name) {
    try {
        return factory.getInstance(name);
    } catch (LogConfigurationException exp) {
        Properties sysProps = System.getProperties();
        // add loaded properties to system properties.
        sysProps.put("org.apache.commons.logging.Log", "phex.utils.PhexLogger");
        LogFactory.releaseAll();
        factory = LogFactory.getFactory();
        return factory.getInstance(name);
    }
}

From source file:phex.common.log.NLogger.java

/**
 * Returns a log instance./*from  w  w  w. ja  va 2s.com*/
 * @param clazz
 * @return a log instance.
 */
public static Log getLogInstance(Class<?> clazz) {
    try {
        return factory.getInstance(clazz);
    } catch (LogConfigurationException exp) {
        Properties sysProps = System.getProperties();
        // add loaded properties to system properties.
        sysProps.put("org.apache.commons.logging.Log", "phex.common.log.PhexLogger");
        LogFactory.releaseAll();
        factory = LogFactory.getFactory();
        return factory.getInstance(clazz);
    }
}

From source file:phex.utils.NLogger.java

/**
 * Returns a log instance.//from w w  w . j  a v a 2 s .c o  m
 * @param clazz
 * @return a log instance.
 */
public static Log getLogInstance(Class clazz) {
    try {
        return factory.getInstance(clazz);
    } catch (LogConfigurationException exp) {
        Properties sysProps = System.getProperties();
        // add loaded properties to system properties.
        sysProps.put("org.apache.commons.logging.Log", "phex.utils.PhexLogger");
        LogFactory.releaseAll();
        factory = LogFactory.getFactory();
        return factory.getInstance(clazz);
    }
}

From source file:pt.lsts.neptus.plugins.tidePrediction.PtHydrographicWeb.java

/**
 * Initializes web client.//from ww  w  .  j  a v  a 2s  .c  om
 */
public PtHydrographicWeb(Harbors harbor) {
    this.harbor = harbor;
    predictions = null;
    webClient = new WebClient();
    webClient.setAjaxController(new NicelyResynchronizingAjaxController());
    LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
            "org.apache.commons.logging.impl.NoOpLog");

    java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(java.util.logging.Level.OFF);
    java.util.logging.Logger.getLogger("org.apache.commons.httpclient").setLevel(java.util.logging.Level.OFF);

    webClient.getOptions().setCssEnabled(false);

    webClient.setIncorrectnessListener(new IncorrectnessListener() {

        @Override
        public void notify(String arg0, Object arg1) {

        }
    });
    webClient.setAlertHandler(new AlertHandler() {

        @Override
        public void handleAlert(Page arg0, String arg1) {

        }
    });
    webClient.setJavaScriptErrorListener(new JavaScriptErrorListener() {

        @Override
        public void timeoutError(HtmlPage arg0, long arg1, long arg2) {

        }

        @Override
        public void scriptException(HtmlPage arg0, ScriptException arg1) {

        }

        @Override
        public void malformedScriptURL(HtmlPage arg0, String arg1, MalformedURLException arg2) {

        }

        @Override
        public void loadScriptError(HtmlPage arg0, URL arg1, Exception arg2) {

        }
    });
    webClient.setHTMLParserListener(new HTMLParserListener() {

        @Override
        public void error(String arg0, URL arg1, String arg2, int arg3, int arg4, String arg5) {

        }

        @Override
        public void warning(String arg0, URL arg1, String arg2, int arg3, int arg4, String arg5) {

        }
    });

    webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
    webClient.getOptions().setThrowExceptionOnScriptError(false);
}