<commit_before>title: Logging and debugging
permalink: /docs/v3/logging-and-debugging/
alias: /docs/logging-and-debugging/
release: v3
type: docs
order: 3
---

Socket.IO is now completely instrumented by a minimalistic yet tremendously powerful utility called [debug](https://github.com/visionmedia/debug) by <NAME>.

Before 1.0, the Socket.IO server would default to logging everything out to the console. This turned out to be annoyingly verbose for many users (although extremely useful for others), so now we default to being completely silent by default.

The basic idea is that each module used by Socket.IO provides different debugging scopes that give you insight into the internals. By default, all output is suppressed, and you can opt into seeing messages by supplying the `DEBUG` env variable (Node.JS) or the `localStorage.debug` property (Browsers).

You can see it in action for example on our homepage:

<video id="debugging-vid" data-setup='{"autoplay":true,"loop":true, "techOrder": ["html5", "flash"], "height": 300}' class="video-js vjs-default-skin" autoplay loop width="100%"><source src="https://i.cloudup.com/transcoded/IL9alTr0eO.mp4" type="video/mp4"></video>

## Available debugging scopes

The best way to see what information is available is to use the `*`:

```
DEBUG=* node yourfile.js
```

or in the browser:

```
localStorage.debug = '*';
```

And then filter by the scopes you&#8217;re interested in. You can prefix the `*` with scopes, separated by comma if there is more than one. For example, to only see debug statements from the socket.io client on Node.js try this:

```
DEBUG=socket.io:client* node yourfile.js
```

To see all debug messages from the engine *and* socket.io:

```
DEBUG=engine,socket.io* node yourfile.js
```


## Removing debug from your browser bundle

While useful during development, the debug package adds an extra weight to the final bundle (about 4KB minified and gzipped), that's why it is excluded from the slim bundle (more details about the various browser bundles can be found [here](/docs/v3/client-installation/#From-a-CDN)).

If you are using webpack, you can remove it with [webpack-remove-debug](https://github.com/johngodley/webpack-remove-debug):

```js
{
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'webpack-remove-debug'
      }
    ]
  }
}
```<commit_msg>docs: add note about error logs in the browser console<commit_after>title: Logging and debugging
permalink: /docs/v3/logging-and-debugging/
alias: /docs/logging-and-debugging/
release: v3
type: docs
order: 3
---

Socket.IO is now completely instrumented by a minimalistic yet tremendously powerful utility called [debug](https://github.com/visionmedia/debug) by <NAME>.

Before 1.0, the Socket.IO server would default to logging everything out to the console. This turned out to be annoyingly verbose for many users (although extremely useful for others), so now we default to being completely silent by default.

The basic idea is that each module used by Socket.IO provides different debugging scopes that give you insight into the internals. By default, all output is suppressed, and you can opt into seeing messages by supplying the `DEBUG` env variable (Node.JS) or the `localStorage.debug` property (Browsers).

You can see it in action for example on our homepage:

<video id="debugging-vid" data-setup='{"autoplay":true,"loop":true, "techOrder": ["html5", "flash"], "height": 300}' class="video-js vjs-default-skin" autoplay loop width="100%"><source src="https://i.cloudup.com/transcoded/IL9alTr0eO.mp4" type="video/mp4"></video>

## Available debugging scopes

The best way to see what information is available is to use the `*`:

```
DEBUG=* node yourfile.js
```

or in the browser:

```
localStorage.debug = '*';
```

And then filter by the scopes you&#8217;re interested in. You can prefix the `*` with scopes, separated by comma if there is more than one. For example, to only see debug statements from the socket.io client on Node.js try this:

```
DEBUG=socket.io:client* node yourfile.js
```

To see all debug messages from the engine *and* socket.io:

```
DEBUG=engine,socket.io* node yourfile.js
```


### Removing debug from your browser bundle

While useful during development, the debug package adds an extra weight to the final bundle (about 4KB minified and gzipped), that's why it is excluded from the slim bundle (more details about the various browser bundles can be found [here](/docs/v3/client-installation/#From-a-CDN)).

If you are using webpack, you can remove it with [webpack-remove-debug](https://github.com/johngodley/webpack-remove-debug):

```js
{
  module: {
    rules: [
      {
        test: /\.js$/,
        loader: 'webpack-remove-debug'
      }
    ]
  }
}
```

## Error logs in the browser console

Please note that error logs such as:

- `net::ERR_INTERNET_DISCONNECTED`
- `net::ERR_CONNECTION_REFUSED`
- `WebSocket is already in CLOSING or CLOSED state`
- `Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at xxx. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).`
- `The connection to xxx was interrupted while the page was loading`

are not emitted by the Socket.IO library but by the browser itself, and are therefore out of our control.
{'fraction_non_alphanumeric': 0.10467748019615239, 'fraction_numerical': 0.008298755186721992, 'mean_word_length': 4.340382678751259, 'pattern_counts': {'":': 8, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3733818', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1515, 'n_words': 649}