Skip to content

selenium.driver.logger

Client, driver-process, and remote logging aggregated for a session.

toWebDriverLevel

string toWebDriverLevel(LogLevel level);

Maps a std.logger level to its WebDriver level string, defaulting to "SEVERE".

fromWebDriverLevel

LogLevel fromWebDriverLevel(string level);

Maps a WebDriver level string to a std.logger level, defaulting to off.

toGeckoDriverLevel

string toGeckoDriverLevel(LogLevel level);

Maps a std.logger level to a geckodriver log.level string.

LogLevel.error maps to "error", warning to "warn", info to "info", trace to "debug", and all to "trace". LogLevel.off and any other level map to "fatal".

Parameters:

Name Description
LogLevel level The std.logger level to map.

Returns: The geckodriver level string.

fromGeckoDriverLevel

LogLevel fromGeckoDriverLevel(string level);

Maps a geckodriver log.level string to a std.logger level.

"fatal" and "error" map to LogLevel.error, "warn" to LogLevel.warning, "info" and "config" to LogLevel.info, "debug" to LogLevel.trace, and "trace" to LogLevel.all. Any other string maps to LogLevel.off.

Parameters:

Name Description
string level The geckodriver level string to map.

Returns: The mapped std.logger level.

LogType

enum LogType: string;

The categories of remote log a driver may expose.

Browser

Browser

Console and page-level browser logs.

Driver

Driver

Logs from the driver implementation.

Client

Client

Logs from the client side of the connection.

Server

Server

Logs from the server side of the connection.

Performance

Performance

Performance and timing logs.

LogEntry

struct LogEntry;

A single remote log record.

timestamp

long timestamp;

Unix timestamp in milliseconds.

level

LogLevel level;

Severity, mapped from the WebDriver level string.

message

string message;

The log message text.

fromJSON

static LogEntry fromJSON(JSONValue json);

Parses an entry from a remote log array element.

Logger

class Logger;

Aggregates every logging concern for a session.

This type is not part of W3C. It presents a single logging surface even though it spans three separate mechanisms: client-side level mapping, driver-process command-line flags, and remote log retrieval. Per-browser logging preferences are folded upward into one logger when a session starts, because Driver.start calls Browser.normalizeLogger for each browser so their levels accumulate here.

The capability and endpoint forms are vendor surfaces rather than W3C. The goog:loggingPrefs capability is a Chromium extension shared by Chrome and Edge, and the /log and /log/types endpoints are legacy commands the W3C spec dropped.

entries

LogEntry[] entries();

The remote log entries drained so far.

levels

LogLevel[string] levels;

Remote log levels per log type, accumulated from each browser's preferences.

path

string path;

Driver-process log file path, passed as a command-line flag.

driverLevel

LogLevel driverLevel;

Driver-process verbosity, passed as a command-line flag.

append

bool append;

Append to the driver log file rather than truncating it.

readableTimestamp

bool readableTimestamp;

Emit human-readable timestamps in the driver log.

silent

bool silent;

Suppress driver-process logging entirely.

toCapabilities

JSONValue toCapabilities() const;

Serializes levels into the goog:loggingPrefs capability object.

toDriverArgs

string[] toDriverArgs() const;

Builds the driver-process command-line flags from the configured fields.

toDriverArgs

string[] toDriverArgs(Browser browser) const;

Builds driver-process command-line flags for a specific browser.

Firefox uses only --log <level> when driverLevel is not LogLevel.off. Chrome, Edge, and WebView2 use --log-path, --log-level, --append-log, --readable-timestamp, and --silent when the corresponding fields are set.

Parameters:

Name Description
Browser browser The browser whose driver is being launched, or null for the
Chromium default.

Returns: The driver command-line arguments or null.

types

string[] types();

Queries the log types the driver exposes via the legacy /log/types command.

fetch

LogEntry[] fetch(string type);

Fetches and clears the pending remote logs of a type.

Uses the legacy /log command, which returns and drains the buffer server side.

Parameters:

Name Description
string type The log type name.

Returns: The pending entries for the type.

fetch

LogEntry[] fetch(LogType type);

Fetches pending remote logs for a typed log category.

drain

LogEntry[] drain(LogType type = LogType.Browser);

Fetches a log type and retains its entries on this logger.

Parameters:

Name Description
LogType type The log type to drain, defaulting to browser logs.

Returns: The fetched entries, which are also appended to entries.