Creating a java.util.logging.LogRecord

Main.java:

import java.util.logging.*;
import java.io.*;
 
public class Main
{
   public static void main(String argv[]){
      Logger logger = Logger.getLogger("main");
      logger.setUseParentHandlers(false);
      ConsoleHandler ch = new ConsoleHandler();
      ch.setLevel(Level.ALL);
      logger.addHandler(ch);
 
      ch.setFormatter(new XMLFormatter());

      LogRecord logRecord = new LogRecord(Level.SEVERE, "Something went seriously wrong");
      logRecord.setMillis(1000);
      logRecord.setParameters(new Object[] { "param1", "param2" });
      logRecord.setSequenceNumber(123456);
      logRecord.setSourceClassName(Main.class.getName());
      logRecord.setSourceMethodName("main");

      logger.log(logRecord); 
   }
}

outputs:

<? xml version="1.0" encoding="windows-1252" standalone="no"?>
<!DOCTYPE log SYSTEM "logger.dtd">
<log>
<record>
  <date>1969-12-31T16:00:01</date>
  <millis>1000</millis>
  <sequence>123456</sequence>
  <level>SEVERE</level>
  <class>Main</class>
  <method>main</method>
  <thread>10</thread>
  <message>Something went seriously wrong</message>
</record>