Package java.util.logging

Examples of java.util.logging.StreamHandler


       
        Logger commandLineLogger = Logger.getLogger(JFit.class.getPackage().getName());
        commandLineLogger.setLevel(Level.FINEST);
        commandLineLogger.setUseParentHandlers(false);
       
        StreamHandler consoleHandler = new SimpleConsoleHandler();

        consoleHandler.setLevel(Level.INFO);
        commandLineLogger.addHandler(consoleHandler);
       
        CommandLineOptions commandLineOptions = CommandLineOptions.parseOptions(args, commandLineLogger);

        if (commandLineOptions == null) {
            // There was an error in the provided command-line args.
            return;
        }
        Level verbosity = commandLineOptions.getVerbosity();
        if (verbosity != null) {
            consoleHandler.setLevel(verbosity);
        }
       
        // Log the boilerplate message.
        commandLineLogger.info(toolBoilerPlate);
        commandLineLogger.info("  '-h' for help.");
View Full Code Here


        }
        iceLogger = Logger.getLogger(iceLoggerNamespace);
        iceLogger.setLevel(Level.FINEST);
        iceLogger.setUseParentHandlers(false);
       
        StreamHandler consoleHandler = new StreamHandler(outputStream, new ConsoleFormatter()) {
           
            /** Override this to always flush the stream. */
            @Override
            public void publish(LogRecord record) {
                super.publish(record);
                flush();
            }
           
            /** Override to just flush the stream, we don't want to close System.out. */
            @Override
            public void close() {
                flush();
            }
        };

        consoleHandler.setLevel(Level.INFO);
        iceLogger.addHandler(consoleHandler);
       
        this.inBuff = new BufferedReader(new BufferedReader(new java.io.InputStreamReader(inputStream)));
       
        // Cache the command line args in an instance field.  These will be used later in
View Full Code Here

    public static void main(String[] args) {
        Logger commandLineLogger = Logger.getLogger(CAL.class.getPackage().getName());
        commandLineLogger.setLevel(Level.FINEST);
        commandLineLogger.setUseParentHandlers(false);
       
        StreamHandler optionsOutputStreamHandler = new OutputStreamStreamHandler(System.out);

        optionsOutputStreamHandler.setLevel(Level.INFO);
        commandLineLogger.addHandler(optionsOutputStreamHandler);
       
        CommandLineOptions options = CommandLineOptions.parseOptions(args, commandLineLogger);
        if (options == null) {
            System.exit(1);
View Full Code Here

        this.workspaceManager = WorkspaceManager.getWorkspaceManager(null);
       
        calLogger.setLevel(Level.FINEST);
        calLogger.setUseParentHandlers(false);
       
        StreamHandler consoleHandler = new OutputStreamStreamHandler(System.out);

        // Note that we can add other handlers which log more about what's happening.
        Level verbosity = options.getVerbosity();
        if (verbosity != null) {
            consoleHandler.setLevel(verbosity);
        } else {
            consoleHandler.setLevel(defaultConsoleLevel);
        }
        calLogger.addHandler(consoleHandler);
       
        // Log set configuration options to the logger.
        options.logConfig(calLogger);
View Full Code Here

   * @param debug whether or not this is in debug mode
   */
  public void debug(boolean debug) {
    this.debug = debug;
    if (debug && debugHandler == null) {
          debugHandler = new StreamHandler(System.out, new SimpleFormatter());
          debugHandler.setLevel(Level.ALL);
    }
  }
View Full Code Here

    String logOutput = props.getProperty(LauncherConstants.PROP_LOG_OUTPUT, LauncherConstants.DEFAULT_LOG_OUTPUT);
    if(logOutput.startsWith("file:")) {
      logOutput = logOutput.substring("file:".length());
      try {
        FileOutputStream stream = new FileOutputStream(logOutput, true);
        handler = new StreamHandler(stream, new SimpleFormatter());
        if(enableDebug)
          System.err.println(MessageFormat.format("Logging to file {0}.", logOutput));
      } catch (FileNotFoundException e) {
        System.err.println(MessageFormat.format("Could not write to specified log file {0}. Falling back to the console.", logOutput));
        handler = new ConsoleHandler();
View Full Code Here

    @Test
    public void testBadResource() throws Exception {
        final ResourceConfig resourceConfig = new ResourceConfig(BadResource.class);

        ByteArrayOutputStream logOutput = new ByteArrayOutputStream();
        Handler logHandler = new StreamHandler(logOutput, new SimpleFormatter());

        GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig, false);

        // TODO: there should be a better way to get the log output!
        final Enumeration<String> loggerNames = LogManager.getLogManager().getLoggerNames();
View Full Code Here

     */
    public static void run(String[] args, OutputStream out) throws Exception {
        // set up logging
        Logger logger = Logger.getLogger(JSParameters.loggerName);
        logger.setUseParentHandlers(false);
        Handler handler = new StreamHandler(out, new JSLogFormatter());
        logger.addHandler(handler);
       
        // parse command line arguments
        JSParameters param = ArgParser.parseArgs(args, null);
        // print help if incorrect or no arguments
View Full Code Here

   * @param debug whether or not this is in debug mode
   */
  public void debug(boolean debug) {
    this.debug = debug;
    if (debug && debugHandler == null) {
          debugHandler = new StreamHandler(System.out, new SimpleFormatter());
          debugHandler.setLevel(Level.ALL);
    }
  }
View Full Code Here

   *          whether or not this is in debug mode
   */
  public synchronized void debug(boolean debug) {
    this.debug = debug;
    if (debug && debugHandler == null) {
      debugHandler = new StreamHandler(System.out, new SimpleFormatter());
      debugHandler.setLevel(Level.ALL);
    }
  }
View Full Code Here

TOP

Related Classes of java.util.logging.StreamHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.