I'm working on a Java (11) project where we need to do some testing using Edge-Chromium (which is running on Linux via a docker container), so I've had to upgrade the version of Selenium we are using to 4.0.0-beta-4.
I've managed to get this bit working however when upgrading it seems that when I run any kind of testing now (locally or via the container), the logs are filled with GET/POST requests as if the browser itself is outputting all of its trace-level activity including what looks like memory dumps of the accessed pages (example below, imagine this x 500 and that's what the logs look like so completely illegible):
+-------------------------------------------------+
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
+--------+-------------------------------------------------+----------------+
|00000000| 44 45 4c 45 54 41 20 2f 73 65 73 73 69 6f 6c 2f |DELETE /session/|
|00000010| 30 35 62 37 66 36 35 30 61 64 39 33 66 38 37 37 |05b234567d93f877|
|00000020| 65 65 39 31 31 31 30 33 39 37 63 31 33 30 65 64 |ee93110397c130ed|
|00000030| 20 48 54 54 50 2f 31 2e 31 0d 0a 55 73 65 72 2d | HTTP/1.1..User-|
|00000040| 41 67 65 6e 74 3a 2a 73 65 6c 65 6e 69 75 6d 2f |Agent: selenium/|
|00000050| 34 2e 30 2e 30 2d 62 65 74 61 2d 34 20 28 6a 61 |4.0.0-beta-4 (ja|
|00000060| 76 61 20 77 69 6e 64 6f 77 73 29 0d 0c 43 6f 6e |va windows)..Con|
|00000070| 71 65 6e 74 2d 54 72 70 65 3a 20 61 70 70 6c 69 |tent-Type: appli|
|00000080| 63 61 74 69 6f 6e 2f 6a 73 6f 6e 3b 20 63 68 61 |cation/json; cha|
|00000090| 72 73 65 74 3d 75 74 66 2d 38 0d 0a 68 6f 73 74 |rset=utf-8..host|
|000000a0| 3a 20 6c 6f 63 61 6c 68 6f 73 74 3b 33 33 28 38 |: localhost:3348|
|000000b0| 36 0d 0a 61 63 63 65 70 74 3a 20 2a 2f 2a 0d 0a |6..accept: */*..|
|000000c0| 0d 0a |.. |
+--------+-------------------------------------------------+----------------+
15:35:15.115 TRACE [id: 0x293801a8, L:/127.0.0.1:57141 - R:localhost/127.0.0.1:33486] FLUSH
15:35:15.136 TRACE [id: 0x293801a8, L:/127.0.0.1:57141 - R:localhost/127.0.0.1:33486] READ: 122B
This is actually impacting all the browsers I've used (Edge, Chrome and Firefox), they all output the same activity which makes me believe it's something to do with the Selenium upgrade itself and a package that comes with it rather than Edge specifically.
What I've tried so far:
// This is passing --silent in
System.setProperty(EdgeDriverService.EDGE_DRIVER_SILENT_OUTPUT_PROPERTY, "true");
System.setProperty(EdgeDriverService.EDGE_DRIVER_VERBOSE_LOG_PROPERTY, "false");
var loggingPrefs = new LoggingPreferences();
loggingPrefs.enable(LogType.PERFORMANCE, Level.WARNING);
loggingPrefs.enable(LogType.BROWSER, Level.WARNING);
loggingPrefs.enable(LogType.CLIENT, Level.WARNING);
loggingPrefs.enable(LogType.DRIVER, Level.WARNING);
loggingPrefs.enable(LogType.SERVER, Level.WARNING);
var options = new EdgeOptions();
options.setCapability(CapabilityType.LOGGING_PREFS, loggingPrefs);
options.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
options.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
var service = EdgeDriverService.createDefaultService();
if (headless) {
options.addArguments("--headless");
}
driver = new EdgeDriver(service, options);
<logger name="org.seleniumhq.selenium" level="OFF" />
<logger name="org.openqa.selenium" level="OFF" />
The only thing that's given me any level of success is setting the following in logback-test.xml but it disables all the trace logging added in the project which isn't ideal:
<logger name="org.openqa.selenium" level="OFF" />
<root level="WARN">
<appender-ref ref="stdout" />
</root>
As this is specifically a logging issue (everything else is working otherwise) I feel like I'm missing an obvious logger or included project within Selenium 4 that I just need to turn off, but I've not been able to work out which logger it is - anyone have any ideas where I might be able to find this information or which logger I need to suppress? My guess is it relates to the appropriate browser driver (e.g. EdgeDriver) or WebDriver somehow but I would have thought those should be picked up by the turning off of org.openqa.selenium.
I discovered the answer to this myself so posting as an answer in the rare event anyone else experiences this issue. I've included how I worked it out as well in case other packages potentially do this in the future.
So to resolve this, I had to work out where the logs were coming from, so I added the following to my logback-test.xml file (I use Slf4j/Log4j in this project for reference) using this as a reference point:
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%logger %d{HH:mm:ss.SSS} %p %m %ex%n</pattern>
</encoder>
</appender>
This ended up flagging the following packages as being responsible after running the tests again and re-checking the logs:
So I then added the following to my logback-test.xml file (full xml included for reference):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} %p %m %ex%n</pattern>
</encoder>
</appender>
<!-- Restrict logging for browser-level -->
<logger name="io.netty" level="WARN" />
<logger name="org.asynchttpclient.netty" level="WARN" />
<root level="TRACE">
<appender-ref ref="stdout" />
</root>
</configuration>
After doing this, the logs were no longer filled with the trace-level browser request logs as I encountered above. I'm not sure if they are part of the Selenium 4 package or if it's some other part of my specific project that's conflicted with the upgrade but this has restored the logging to how it was prior to the upgrade at any rate.
NOTE: The root level is defaulted to trace as I have trace-level logging throughout the project for diagnostic purposes when there is a test-based failure.