Reputation: 33
I'm using Intellij with jdk 14 to build a seleninum test. I just want the console output as test report, result or error. I've tried many ways found on google or stackoverflow such as setting the loglevel, grep console but these messages still appear. Is there any way to resolve this issue? Here is the output:
16:44:14.551 [main] DEBUG io.netty.buffer.PooledByteBufAllocator - -Dio.netty.allocator.maxCachedByteBuffersPerChunk: 1023
16:44:14.559 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled
16:44:14.560 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 0
16:44:14.560 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384
Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 7431
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
16:44:15.681 [Forwarding newSession on session null to remote] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.processId: 17484 (auto-detected)
16:44:15.683 [Forwarding newSession on session null to remote] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv4Stack: false
16:44:15.683 [Forwarding newSession on session null to remote] DEBUG io.netty.util.NetUtil - -Djava.net.preferIPv6Addresses: false
16:44:15.689 [Forwarding newSession on session null to remote] DEBUG io.netty.util.NetUtil - Loopback interface: lo (Software Loopback Interface 1, 127.0.0.1)
16:44:15.689 [Forwarding newSession on session null to remote] DEBUG io.netty.util.NetUtil - Failed to get SOMAXCONN from sysctl and file \proc\sys\net\core\somaxconn. Default: 200
16:44:15.696 [Forwarding newSession on session null to remote] DEBUG io.netty.channel.DefaultChannelId - -Dio.netty.machineId: fc:aa:14:ff:fe:e6:1d:11 (auto-detected)
16:44:15.758 [AsyncHttpClient-3-1] DEBUG io.netty.buffer.AbstractByteBuf - -Dio.netty.buffer.checkAccessible: true
16:44:15.758 [AsyncHttpClient-3-1] DEBUG io.netty.buffer.AbstractByteBuf - -Dio.netty.buffer.checkBounds: true
16:44:15.759 [AsyncHttpClient-3-1] DEBUG io.netty.util.ResourceLeakDetectorFactory - Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector@3d005e97
16:44:15.777 [AsyncHttpClient-3-1] DEBUG org.asynchttpclient.netty.channel.NettyConnectListener - Using new Channel '[id: 0x09b55496, L:/127.0.0.1:54163 - R:localhost/127.0.0.1:7431]' for 'POST' to '/session'
16:44:15.829 [AsyncHttpClient-3-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.maxCapacityPerThread: 4096
16:44:15.829 [AsyncHttpClient-3-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.maxSharedCapacityFactor: 2
16:44:15.829 [AsyncHttpClient-3-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.linkCapacity: 16
16:44:15.830 [AsyncHttpClient-3-1] DEBUG io.netty.util.Recycler - -Dio.netty.recycler.ratio: 8
16:44:20.511 [AsyncHttpClient-3-1] DEBUG org.asynchttpclient.netty.handler.HttpHandler -
Request DefaultHttpRequest(decodeResult: success, version: HTTP/1.1)
POST /session HTTP/1.1
User-Agent: selenium/4.0.0-alpha-6 (java windows)
Content-Length: 365
Content-Type: application/json; charset=utf-8
host: localhost:7431
accept: */*
Upvotes: 0
Views: 2193
Reputation: 495
For anyone with a similar request but using log4j, you could also use code to set up logging. The following removes the verbose netty debug messages:
BasicConfigurator.resetConfiguration();
Logger.getRootLogger().setLevel(Level.INFO);
String pattern = "%p: %m %n";
BasicConfigurator.configure(new ConsoleAppender(new PatternLayout(pattern)));
Upvotes: 0
Reputation: 2846
What you really need to do is to set the log level on the console log handler (which is responsible for printing all log messages to the console). However doing this whilst using BasicConfigurator
will be quite tricky to do, you are better off moving to having your logging configuration specified in a properties file (which is much more flexible).
I would advise working through the log4j logging configuration tutorial - this will help you put together exactly the configuration you want, and should prove a worthwhile investment of your time. However, if you want to get this done quickly, try adding the content below to the file log4j.properties
(example taken from here):
# Root logger option
log4j.rootLogger=INFO, stdout
# Direct log messages to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
And then changing your code to do the following:
Properties props = new Properties();
props.load(new FileInputStream("/my/path/to/log4j.properties"));
PropertyConfigurator.configure(props);
Upvotes: 2