Example #1
0
  public void test(TestHarness th) {
    LogRecord rec = new LogRecord(Level.CONFIG, "foo");

    // Check #1.
    rec.setMillis(12345);
    th.check(rec.getMillis(), 12345);

    // Check #2.
    rec.setMillis(-54321);
    th.check(rec.getMillis(), -54321);
  }
Example #2
0
  public static void main(String[] args) {
    for (int i = 1; i <= 5; i++) {
      LogRecord logRecord = new LogRecord(Level.SEVERE, "This is a severe message #" + i + "!");

      logRecord.setLoggerName("test app");
      logRecord.setMillis(System.currentTimeMillis());
      logRecord.setParameters(new Object[] {Thread.currentThread().getName()});
      logRecord.setSourceClassName(HTMLFormatter.class.getName());
      logRecord.setSourceMethodName("SourceMethodName");

      System.out.print(new HTMLFormatter().format(logRecord));

      logRecord = new LogRecord(Level.WARNING, "This is a warning message #" + i + "!");

      logRecord.setLoggerName("test app");
      logRecord.setMillis(System.currentTimeMillis());
      logRecord.setParameters(new Object[] {Thread.currentThread().getName()});
      logRecord.setSourceClassName(HTMLFormatter.class.getName());
      logRecord.setSourceMethodName("SourceMethodName");

      System.out.print(new HTMLFormatter().format(logRecord));
    }
  }