Java examples for Java Virtual Machine:Logger
Writing Log Records Only After a Condition Occurs
import java.awt.Graphics; import java.io.IOException; import java.util.logging.FileHandler; import java.util.logging.Level; import java.util.logging.Logger; import java.util.logging.MemoryHandler; public class Main { public void m() { try {//w ww.j a v a 2 s. c om FileHandler fhandler = new FileHandler("my.log"); int numRec = 100; MemoryHandler mhandler = new MemoryHandler(fhandler, numRec, Level.SEVERE); // Add to the desired logger Logger logger = Logger.getLogger("com.mycompany"); logger.addHandler(mhandler); } catch (IOException e) { } } }