'WebdriverIO with devtools is printing a lot of data in console

Currently I am working with web driver in order to get the trace of the devtools in a session with the following script:

   browser.startTracing()
    $(visitWebsiteBuilder).click()
    browser.pause(10000)
    browser.endTracing()
    fs.writeFileSync('trace.json', JSON.stringify(browser.getTraceLogs()))

It seems to work fine but the execution is generating a lot of logs in the console:

{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 4488,
  tid: 11488,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 4488,
  tid: 15860,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 4488,
  tid: 17180,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 4488,
  tid: 17216,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 4488,
  tid: 17200,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 16392,
  tid: 15884,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 15148,
  tid: 9644,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 4488,
  tid: 16312,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 4488,
  tid: 15372,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 4488,
  tid: 13752,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 16392,
  tid: 4852,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 16392,
  tid: 14476,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 16392,
  tid: 16380,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 16392,
  tid: 8300,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 4488,
  tid: 5108,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 16392,
  tid: 7568,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 16392,
  tid: 13168,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 16392,
  tid: 13768,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 16392,
  tid: 17864,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 16392,
  tid: 10796,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 16392,
  tid: 6432,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 15148,
  tid: 16248,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'thread_name',
  ph: 'M',
  pid: 3036,
  tid: 8136,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'process_name',
  ph: 'M',
  pid: 4488,
  tid: 0,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'process_name',
  ph: 'M',
  pid: 15148,
  tid: 0,
  ts: 0
},
{
  args: [Object],
  cat: '__metadata',
  name: 'process_name',
  ph: 'M',
  pid: 3036,
  tid: 0,
  ts: 0
},

And a lot of info related to the browser. I have tried to changes the logging level in the wdio.config.js with the following options:

  // Level of logging verbosity: trace | debug | info | warn | error | silent
logLevel: 'silent',
//
// Set specific log levels per logger
// use 'silent' level to disable logger
logLevels: {
    webdriver: 'silent',
    devtools: 'silent'
},

but it stills printing that data and it floods the console, any idea about how to avoid this?

UPDATE #1 I tried to specify the log folder and now it is logging and creating the log files, but it stills printing the trace in the console: EvidenceScreenshot

UPDATE 2 Adding the package.json code:

{
  "name": "event_tracker_nhs",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "npx wdio wdio.conf.js"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@wdio/allure-reporter": "^6.4.6",
    "@wdio/cli": "^6.4.5",
    "@wdio/devtools-service": "^6.5.2",
    "@wdio/dot-reporter": "^6.3.6",
    "@wdio/local-runner": "^6.4.4",
    "@wdio/mocha-framework": "^6.4.0",
    "@wdio/spec-reporter": "^6.4.0",
    "@wdio/sync": "^6.4.0",
    "chai": "^4.2.0",
    "chromedriver": "^84.0.1",
    "devtools": "^6.4.4",
    "mocha": "^8.1.3",
    "mocha.parallel": "^0.15.6",
    "wdio-chromedriver-service": "^6.0.3",
    "webdriverio": "^6.4.6"
    },
    "dependencies": {
      "axios": "^0.19.2",
      "request-promise": "^4.2.6"
   }
}


Solution 1:[1]

LE-02: I am running wdio-v5 currently, but either way, the behaviour should be the same. We can try another thing, seeing as you are using chromedriver to run your checks, you can go and override the chromedriver service log settings:

services: [
  ['chromedriver', {
      logFileName: 'wdio-chromedriver.log', // >> your log file name
      outputDir: 'driver-logs',             // >> this will overwrite config.outputDir
      args: ['--silent']
  }]
],

If you don't want your browser logs to be dumped in the console, make sure you setup the outputDir option inside your wdio.conf.js file.

What will the effects be? Quoting the DOCS:

Directory to store all testrunner log files (including reporter logs and wdio logs). If not set, all logs are streamed to stdout. Since most reporters are made to log to stdout, it is recommended to only use this option for specific reporters where it makes more sense to push report into a file (like the junit reporter, for example).

So just add outputDir: '<folderPath>', inside the wdio.conf.js file and you'll get the browser & webdriver log files in the given folder.

After you set it up, you should see the wdio log files inside the designated folder.


LE-01: I just ran your commands and the logs are pipped accordingly to the wdio-0-0.log file.

enter image description here

Solution 2:[2]

It may depend on your situation and the different versions of WebdriverIO, but you can try:

  const browser = await remote({
    capabilities: {
      browserName: "chrome"
    },
    logLevel: "silent"
  });

Solution 3:[3]

Try providing log level in the capabilities section, it works for me

capabilities: [{
    maxInstances: 1,
    browserName: 'chrome',
    acceptInsecureCerts: true,
    logLevel:"silent"
}],

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 nonopolarity
Solution 3