electron/docs/api/net-log.md
Shelley Vohr d87b3ead76 chore: remove promisification deprecation callbacks (#17907)
* chore: remove promisification deprecation callbacks

* update docs

* fix smoke test

* fix executejs issue

* cleanup leftovers

* fix webContents.executeJavaScript tests

* cleanup WebContents.prototype.takeHeapSnapshot

* fix "sets arbitrary webContents as devtools" test

* fix executeJavaScriptInFrame related tests
2019-04-30 07:08:32 -07:00

1.1 KiB

netLog

Logging network events for a session.

Process: Main

const { netLog } = require('electron')

app.on('ready', async function () {
  netLog.startLogging('/path/to/net-log')
  // After some network events
  const path = await netLog.stopLogging()
  console.log('Net-logs written to', path)
})

See --log-net-log to log network events throughout the app's lifecycle.

Note: All methods unless specified can only be used after the ready event of the app module gets emitted.

Methods

netLog.startLogging(path)

  • path String - File path to record network logs.

Starts recording network events to path.

netLog.stopLogging()

Returns Promise<String> - resolves with a file path to which network logs were recorded.

Stops recording network events. If not called, net logging will automatically end when app quits.

Properties

netLog.currentlyLogging

A Boolean property that indicates whether network logs are recorded.

netLog.currentlyLoggingPath

A String property that returns the path to the current log file.