Package org.objectweb.util.monolog.api

Examples of org.objectweb.util.monolog.api.Handler


    TopicalLogger l = (TopicalLogger) mf.getLogger(
      "org.objectweb.util.monolog.TestHandlerLevel.testA");
    l.setIntLevel(BasicLevel.DEBUG);
    l.setAdditivity(false);

    Handler h1 = mf.createHandler("h1", "console");
    h1.setAttribute(Handler.OUTPUT_ATTRIBUTE, "System.out");
    h1.setAttribute(Handler.LEVEL_ATTRIBUTE, "WARN");
    h1.setAttribute(Handler.PATTERN_ATTRIBUTE, "first handler: %m");
    h1.setAttribute("activation",mf);
    l.addHandler(h1);

    Handler h2 = mf.createHandler("h2", "console");
    h2.setAttribute(Handler.OUTPUT_ATTRIBUTE, "System.out");
    h2.setAttribute(Handler.PATTERN_ATTRIBUTE, "second handler: %m");
    h2.setAttribute("activation",mf);
    l.addHandler(h2);
    l = (TopicalLogger) mf.getLogger(
      "org.objectweb.util.monolog.TestHandlerLevel.testA.l1");
    l.log(BasicLevel.DEBUG, "(" + className + ") this message must be printed only one time");
  }
View Full Code Here


  public void testSimple() {
    quietRootLogger();
    TopicalLogger l = (TopicalLogger)
      lf.getLogger("test.configurability.simple");
    Handler hc =
      hf.createHandler("myhandler_configurability", "file");
    hc.setAttribute(Handler.OUTPUT_ATTRIBUTE, "test.log");
    hc.setAttribute(Handler.PATTERN_ATTRIBUTE, "%m%n");
    hc.setAttribute("activation", lf);
    try {
      l.addHandler(hc);
    }
    catch (Exception e) {
      fail(e.getMessage());
View Full Code Here

  public void testA() {
    quietRootLogger();
    TopicalLogger l1 = (TopicalLogger) lf.getLogger("test.additivity");
    TopicalLogger l2 = (TopicalLogger) lf.getLogger("test.additivity.foo");
    Handler hc1 = hf.createHandler("myhandler", "file");
    hc1.setAttribute(Handler.OUTPUT_ATTRIBUTE, LOG_FILE_NAME + '1');
    hc1.setAttribute(Handler.PATTERN_ATTRIBUTE, LOG_PATTERN);
    hc1.setAttribute("activation", lf);
    Handler hc2 = hf.createHandler("myhandler2", "file");
    hc2.setAttribute(Handler.OUTPUT_ATTRIBUTE, LOG_FILE_NAME + '2');
    hc2.setAttribute(Handler.PATTERN_ATTRIBUTE, LOG_PATTERN);
    hc2.setAttribute("activation", lf);
    try {
      l1.addHandler(hc1);
      l2.addHandler(hc2);
    }
    catch (Exception e) {
View Full Code Here

  }
  public void testB() {
    quietRootLogger();
    TopicalLogger l1 = (TopicalLogger) lf.getLogger("test.additivity");
    TopicalLogger l2 = (TopicalLogger) lf.getLogger("test.additivity.foo");
    Handler hc1 =
      hf.createHandler("myhandler", "file");
    hc1.setAttribute(Handler.OUTPUT_ATTRIBUTE, LOG_FILE_NAME + '1');
    hc1.setAttribute(Handler.PATTERN_ATTRIBUTE, LOG_PATTERN);
    hc1.setAttribute("activation", lf);
    Handler hc2 = hf.createHandler("myhandler2", "file");
    hc2.setAttribute(Handler.OUTPUT_ATTRIBUTE, LOG_FILE_NAME + '2');
    hc2.setAttribute(Handler.PATTERN_ATTRIBUTE, LOG_PATTERN);
    hc2.setAttribute("activation", lf);
    try {
      l1.addHandler(hc1);
      l2.addHandler(hc2);
    }
    catch (Exception e) {
View Full Code Here

  public void testSimple() {
    quietRootLogger();
        new File(LOG_FILE_NAME).delete();
    l = (TopicalLogger) lf.getLogger("test.pw2logger.foo");
        l.setIntLevel(BasicLevel.DEBUG);
    Handler h = hf.createHandler("pw2logger", "file");
    h.setAttribute(Handler.OUTPUT_ATTRIBUTE, LOG_FILE_NAME);
    h.setAttribute(Handler.PATTERN_ATTRIBUTE, LOG_PATTERN);
    h.setAttribute("activation", hf);
    try {
      l.addHandler(h);
    } catch (Exception e) {
      fail(e.getMessage());
    }
View Full Code Here

        lef.defineLevel("WARNbis", "WARN"));

      lef.defineLevel("FATAL", "50000");

      //------ Handler ------//
      Handler h = hf.createHandler("handler_sys_out", "console");
      h.setAttribute(Handler.OUTPUT_ATTRIBUTE, "System.out");
      h.setAttribute(Handler.PATTERN_ATTRIBUTE, "%m%n");
      h.setAttribute("activation", hf);

      h = hf.createHandler("Handler_file", "file");
      h.setAttribute(Handler.OUTPUT_ATTRIBUTE, "toto.txt");
      h.setAttribute(Handler.PATTERN_ATTRIBUTE, "%p %m%n");
      h.setAttribute("activation", hf);

      h = hf.createHandler("Handler.rolling.file", "rollingfile");
      h.setAttribute(Handler.OUTPUT_ATTRIBUTE, "toto");
      h.setAttribute(Handler.MAX_SIZE_ATTRIBUTE, "300");
      h.setAttribute(Handler.FILE_NUMBER_ATTRIBUTE, "2");
      h.setAttribute(Handler.PATTERN_ATTRIBUTE, "%p - %m%n");
      h.setAttribute("activation", hf);


      //------ Logger ------//

      TopicalLogger l = null;
View Full Code Here

    assertEquals("level: LOAD_DEBUG2: bad string expr",
      String.valueOf(BasicLevel.DEBUG + 2),
      ((LevelImpl) le).getStringValue());

    //------ Handler ------//
    Handler h = null;
    h = hf.getHandler("myhandler1");
    assertNotNull("handler: myhandler1: undefined", h);
    assertEquals("handler: myhandler1: bad type",
      PropertiesConfAccess.HANDLER_TYPE_ATTRIBUTE_CONSOLE_VALUE, h.getType());
    assertEquals("handler: myhandler1: bad output",
      "System.out", h.getAttribute(Handler.OUTPUT_ATTRIBUTE));
    assertEquals("handler: myhandler1: bad pattern",
      "%m%n", h.getAttribute(Handler.PATTERN_ATTRIBUTE));

    h = hf.getHandler("test.load.myhandler2");
    assertNotNull("handler: test.load.myhandler2: undefined", h);
    assertEquals("handler: test.load.myhandler2: bad type",
      PropertiesConfAccess.HANDLER_TYPE_ATTRIBUTE_FILE_VALUE, h.getType());
    assertEquals("handler: test.load.myhandler2: bad output",
      "myhandler2.log", h.getAttribute(Handler.OUTPUT_ATTRIBUTE));
    assertEquals("handler: test.load.myhandler2: bad pattern",
      "=> %m%n", h.getAttribute(Handler.PATTERN_ATTRIBUTE));

    h = hf.getHandler("test.load.myhandler3");
    assertNotNull("handler: test.load.myhandler3: undefined", h);
    assertEquals("handler: test.load.myhandler3: bad type",
      PropertiesConfAccess.HANDLER_TYPE_ATTRIBUTE_ROLLING_FILE_VALUE, h.getType());
    assertEquals("handler: test.load.myhandler2: bad output",
      "myhandler3.log", h.getAttribute(Handler.OUTPUT_ATTRIBUTE));
    assertEquals("handler: test.load.myhandler2: bad pattern",
      "-> %m%n", h.getAttribute(Handler.PATTERN_ATTRIBUTE));
    assertEquals("handler: test.load.myhandler2: bad file number",
      "2", h.getAttribute(Handler.FILE_NUMBER_ATTRIBUTE));
    assertEquals("handler: test.load.myhandler2: bad max size",
      "20", h.getAttribute(Handler.MAX_SIZE_ATTRIBUTE));

    //------ Logger ------//
    TopicalLogger l = null;
    l = (TopicalLogger) lf.getLogger("test.load.bar");
    assertEquals("logger: test.load.bar: bad level",
View Full Code Here

        }
        return hns;
    }

    public Map getHandlerAttributes(String handlername) throws RemoteException {
        Handler h = mf.getHandler(handlername);
        String[] ans = h.getAttributeNames();
        Map m = new HashMap(ans.length);
        for(int i=0; i<ans.length; i++) {
            m.put(ans[i], h.getAttribute(ans[i]));
        }
        return m;
    }
View Full Code Here

        return m;
    }

    public void setHandlerAttribute(String handlername, String attributeName,
            String value) throws RemoteException {
        Handler h = mf.getHandler(handlername);
        if (h == null) {
            throw new RemoteException("No handler '" + handlername + "' found.");
        }
        h.setAttribute(attributeName, value);
    }
View Full Code Here

        return lis;
    }

    public void addHandlerToLogger(String handlername, String loggerName)
            throws RemoteException {
        Handler h = mf.getHandler(handlername);
        if (h == null) {
            throw new RemoteException("No handler '" + handlername + "' found.");
        }
        TopicalLogger l = (TopicalLogger) mf.getLogger(loggerName);
        try {
View Full Code Here

TOP

Related Classes of org.objectweb.util.monolog.api.Handler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.