---
title: Log from a plugin
description: Write meaningful events from your Volumio plugin to the Volumio log with this.logger, and read them with volumio-plugin logs.
---

Write the events that matter in your plugin to the Volumio log, and read them while you test. The log is how you and Volumio's support find out why a plugin failed on a user's device.

## Write a log line

The template keeps Volumio's logger as `this.logger`. Start each line with the plugin's id, so you can find your lines among the others. `deploy` shows only the lines that name the plugin, and every warning and error:

```js title="index.js"
this.logger.info('hello_volumio: connected to the service');
this.logger.error(`hello_volumio: login failed: ${error.message}`);
```

The logger has four levels:

| Level | Use it for | Example |
| --- | --- | --- |
| `info` | A normal event | The plugin started, the settings were saved |
| `warn` | A problem the plugin worked around | An optional request failed |
| `error` | A failure | A daemon did not start, a login failed |
| `debug` | Detail you need only while you develop | Each request and its answer |

Volumio's logger is [winston](https://github.com/winstonjs/winston).

## Keep the log useful

- Log events, not every step. A busy log hides the line that matters and costs processor time on small devices.
- Never log a password, a token or anything else the user typed as a secret.
- Never use `console.log`. It bypasses the Volumio logger, and `volumio-plugin check` reports it as `G2.js.console-log`.

## Read the log

Follow the device's log from your computer while you use the plugin:

```sh
npx --package=@volumio/plugin-sdk volumio-plugin logs 192.168.1.20
```

It runs until you press Ctrl+C. Add `--seconds 30` to stop after 30 seconds. `logs` needs Node.js 22 or later.

`volumio-plugin deploy` also prints the lines the device logged about the plugin while it started. See [Test on a Volumio device](/plugins/how-to/test-on-a-device).

## Related

- [Troubleshooting](/plugins/troubleshooting)
- [volumio-plugin CLI](/plugins/reference/cli#logs)
