Beispiel #1
0
  private static void writeLogRecords(PrintStream logps) throws Exception {
    PrintStream err = System.err;
    try {
      System.setErr(logps);

      Object[] params = new Object[] {new Long(1), "string"};
      PlatformLogger plog = PlatformLogger.getLogger("test.log.foo");
      plog.severe("Log message {0} {1}", (Object[]) params);

      // create a java.util.logging.Logger
      // now java.util.logging.Logger should be created for each platform
      // logger
      Logger logger = Logger.getLogger("test.log.bar");
      logger.log(Level.SEVERE, "Log message {0} {1}", params);

      plog.severe("Log message {0} {1}", (Object[]) params);
    } finally {
      logps.flush();
      logps.close();
      System.setErr(err);
    }
  }
 private static void printFailMsg(
     Vector<String> expNames, Vector<String> retNames, String failMsg) {
   out.println();
   out.println(failMsg);
   if (expNames.size() == 0) {
     out.println("# there are NO expected logger names");
   } else {
     out.println("# expected logger names (" + expNames.size() + "):");
     for (int i = 0; i < expNames.size(); i++) {
       out.println(" expNames[" + i + "] = " + expNames.elementAt(i));
     }
   }
   if (retNames.size() == 0) {
     out.println("# there are NO returned logger names");
   } else {
     out.println("# returned logger names (" + retNames.size() + "):");
     for (int i = 0; i < retNames.size(); i++) {
       out.println("  retNames[" + i + "] = " + retNames.elementAt(i));
     }
   }
 }