Package org.objectweb.util.monolog.api

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


  }

  public void testProgConfig() throws Exception {
    String className = System.getProperty(Monolog.MONOLOG_CLASS_NAME, Monolog.JDK_WRAPPER_CLASS_NAME);
    Monolog.monologFactory = Monolog.getDefaultMonologFactory();
    MonologFactory mf = Monolog.instanciateMonologFactory(className);
    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


        "java SpecificConf <logger factory class name> <mode> "
        + "[<config file name> [ true | false ]]");
      System.exit(1);
    }
    // Instanciate the logger factory
    MonologFactory lf = null;
    try {
      lf = (MonologFactory) Class.forName(args[0]).newInstance();
    } catch (ClassCastException e) {
      throw new ClassCastException(
        "The specified class is not a Logger factory: " + args[0]);
    } catch (Exception e) {
      throw new ClassCastException(
        "Logger factory class is not availlable: " + args[0]);
    }

    String mode = (args.length>1 ? args[1] : null);
    Properties prop = null;
    if (mode != null && !mode.equalsIgnoreCase("null")) {
      String configFileName = (args.length>2 ? args[2] : null);
      prop = new Properties();
      prop.put(MonologFactory.LOG_CONFIGURATION_TYPE, mode);
      if (configFileName != null) {
        prop.put(MonologFactory.LOG_CONFIGURATION_FILE, configFileName);
      }

      String useClassPath = (args.length>3 ? args[3] : null);
      if (useClassPath != null) {
        prop.put(MonologFactory.LOG_CONFIGURATION_FILE_USE_CLASSPATH,
          useClassPath);
      }
    }
    //load the configuration
    try {
      lf.configure(prop);
    } catch (Exception e) {
      System.out.println("Impossible to configure in " + mode + " mode: "
        + e.getMessage());
      System.exit(1);
    }
View Full Code Here

    if (!key.equalsIgnoreCase("activation")) {
      return prop.put(key, value);
    } else if (prop.containsKey(key)) {
        return null; //already activated
    }
    MonologFactory mf = (MonologFactory) value;
    String source = (String) prop.get("source");
    if (source != null) {
        setSource((String) value);
    }
    String pattern = (String) prop.get(Handler.PATTERN_ATTRIBUTE);
View Full Code Here

    if (!key.equalsIgnoreCase("activation")) {
      return prop.put(key, value);
    } else if (prop.containsKey(key)) {
        return null; //already activated
    }
    MonologFactory mf = (MonologFactory) value;
    String append = (String) prop.get(Handler.APPEND_MODE_ATTRIBUTE);
    if (append != null && append.length() > 0) {
      fileAppend = Boolean.getBoolean(append);
    } else {
      fileAppend = true;
View Full Code Here

    if (!key.equalsIgnoreCase("activation")) {
      return prop.put(key, value);
    } else if (prop.containsKey(key)) {
        return null; //already activated
    }
    MonologFactory mf = (MonologFactory) value;
    String output = (String) prop.get(Handler.OUTPUT_ATTRIBUTE);
    output = RelatifEnvironmentPathGetter.getRealPath(output);
    String append = (String) prop.get(Handler.APPEND_MODE_ATTRIBUTE);
    if (append != null && append.length() > 0) {
      fileAppend = Boolean.getBoolean(append);
View Full Code Here

    if (!key.equalsIgnoreCase("activation")) {
      return prop.put(key, value);
    } else if (prop.containsKey(key)) {
        return null; //already activated
    }
    MonologFactory mf = (MonologFactory) value;
    String pattern = (String) prop.get(Handler.PATTERN_ATTRIBUTE);
    if (pattern != null) {
        setLayout(new PatternLayout(PatternConverter.monolog2log4j(pattern)));
    }
   
View Full Code Here

            return attributes.put(_name, value);
        }
    if (type == null) {
      type = (String) attributes.get("handlertype");
    }
        MonologFactory mf = (MonologFactory) value;
        String output = (String) attributes.get(Handler.OUTPUT_ATTRIBUTE);
        output = RelatifEnvironmentPathGetter.getRealPath(output);
        String pattern = (String) attributes.get(Handler.PATTERN_ATTRIBUTE);
        String level = (String) attributes.get(Handler.LEVEL_ATTRIBUTE);
        String append = (String) attributes.get(Handler.APPEND_MODE_ATTRIBUTE);
View Full Code Here

    if (!key.equalsIgnoreCase("activation")) {
      return prop.put(key, value);
    } else if (prop.containsKey(key)) {
        return null; //already activated
    }
    MonologFactory mf = (MonologFactory) value;
    String pattern = (String) prop.get(Handler.PATTERN_ATTRIBUTE);
    if (pattern != null) {
        setLayout(new PatternLayout(PatternConverter.monolog2log4j(pattern)));
    }
    String level = (String) prop.get(Handler.LEVEL_ATTRIBUTE);
View Full Code Here

TOP

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

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.