Selenium for Java by default uses java.utils.logging (JUL) infrastructure for logging. During development I have seen logs like:
Nov 21, 2016 8:16:32 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Nov 21, 2016 8:16:34 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
I am using log4j2 through slf4j and just creating logger in configuration file did not worked. Solution was:
1. Add Gradle/Maven dependency to log4j-jul
2. As documentation says set system property “java.util.logging.manager” to “org.apache.logging.log4j.jul.LogManager” either via -D parameter or in Main like:
public static void main(String[] args) {
System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager");
...
}
It must be set BEFORE any call to log4j!!!
3. Define log4j logger:
<Logger name="org.openqa.selenium" level="warn" additivity="false">
<AppenderRef ref="console"/>
</Logger>
And unnecessary logs are gone!