Example usage for org.openqa.selenium.remote.server.log LoggingOptions getDefaultLogLevel

List of usage examples for org.openqa.selenium.remote.server.log LoggingOptions getDefaultLogLevel

Introduction

In this page you can find the example usage for org.openqa.selenium.remote.server.log LoggingOptions getDefaultLogLevel.

Prototype

public static Level getDefaultLogLevel() 

Source Link

Usage

From source file:org.openqa.grid.selenium.GridLauncherV3.java

License:Apache License

private static void configureLogging(StandaloneConfiguration configuration) {
    Level logLevel = configuration.debug ? Level.FINE : LoggingOptions.getDefaultLogLevel();
    if (logLevel == null) {
        logLevel = Level.INFO;//from   w  ww  .jav  a2s.  com
    }
    Logger.getLogger("").setLevel(logLevel);
    Logger.getLogger("org.openqa.jetty").setLevel(Level.WARNING);

    String logFilename = configuration.log != null ? configuration.log : LoggingOptions.getDefaultLogOutFile();
    if (logFilename != null) {
        for (Handler handler : Logger.getLogger("").getHandlers()) {
            if (handler instanceof ConsoleHandler) {
                Logger.getLogger("").removeHandler(handler);
            }
        }
        try {
            Handler logFile = new FileHandler(new File(logFilename).getAbsolutePath(), true);
            logFile.setFormatter(new TerseFormatter(true));
            logFile.setLevel(logLevel);
            Logger.getLogger("").addHandler(logFile);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    } else {
        for (Handler handler : Logger.getLogger("").getHandlers()) {
            if (handler instanceof ConsoleHandler) {
                handler.setLevel(logLevel);
                handler.setFormatter(new TerseFormatter(configuration.logLongForm));
            }
        }
    }
}