Logger: setUseParentHandlers(boolean useParentHandlers) : Logger « java.util.logging « Java by API






Logger: setUseParentHandlers(boolean useParentHandlers)

  

import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Logger;

public class MainClass {
  private static Logger logger = Logger.getLogger("MultipleHandlers2");

  public static void main(String[] args) throws Exception {
    FileHandler logFile = new FileHandler("MultipleHandlers2.xml");
    logger.addHandler(logFile);
    logger.addHandler(new ConsoleHandler());
    logger.setUseParentHandlers(false);
    logger.warning("Output to multiple handlers");
  }
}

   
    
  








Related examples in the same category

1.Logger: addHandler(Handler handler)
2.Logger: config(String msg)
3.Logger: exiting(String sourceClass, String sourceMethod, Object result)
4.Logger: fine(String msg)
5.Logger: finer(String msg)
6.Logger: finest(String msg)
7.Logger: getAnonymousLogger()
8.Logger: getLogger(String name)
9.Logger: info(String msg)
10.Logger: isLoggable(Level level)
11.Logger: logp(Level level, String sourceClass, String sourceMethod, String msg)
12.Logger: severe(String msg)
13.Logger: setFilter(Filter newFilter)
14.Logger: warning(String msg)