FileHandler: publish(LogRecord record) : FileHandler « java.util.logging « Java by API






FileHandler: publish(LogRecord record)

  

import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.XMLFormatter;

public class Main {
  public static void main(String args[]) throws Exception{
    XMLFormatter formatter = new XMLFormatter();
    LogRecord record = new LogRecord(Level.INFO, "XML message..");

    FileHandler handler = new FileHandler("newxml.xml");
    handler.setFormatter(formatter);

    handler.publish(record);
    handler.flush();
  }
}

   
    
  








Related examples in the same category

1.new FileHandler(String pattern)
2.FileHandler: close()