---
title: "Logs | wasmCloud"
description: "How to get the most out of logs in a distributed system"
canonical: "https://wasmcloud.com/docs/v1/deployment/observability/logs/"
---

This is documentation for wasmCloud **v1**, which is no longer actively maintained.

For up-to-date documentation, see the **[latest version](https://wasmcloud.com/docs/)** (v2).

Version: v1

# Logs

## Simple logging (local)

Logs written to [STDERR](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_%28stderr%29) by components and providers may be observed in the logs of the *host* on which the component/provider is running.

Writing to STDERR looks different in various languages, but is usually simple to accomplish:

**Go**

go

```go
fmt.Fprintf(os.Stderr, "your log message here")
// log.Print("Hello, log file!") // alternatively, 'log' can be used, which writes to STDERR by default
```

**Rust**

rust

```rust
eprintln!("your message here");
```

**TypeScript**

typescript

```typescript
console.error("your message here");
```

> **Warning**
>
> Logs sent to STDOUT will *not* be appended to host logs.

This simple logging scheme is useful for local debugging and or simple logging schemes.

## Structured logging and OpenTelemetry

In addition to host-level logging, wasmCloud supports log exports using the [OpenTelemetry (OTEL)](https://opentelemetry.io/) specification.

For more information on wasmCloud's implementation of OpenTelemetry, including advanced configuration options, see [Observability with OpenTelemetry](https://wasmcloud.com/docs/v1/deployment/observability/observability-with-opentelemetry/).

### Configuration

By default, wasmCloud hosts write `info` level logs to `stderr` in plaintext.

To enable all OTEL signals, including logs, use the `WASMCLOUD_OBSERVABILITY_ENABLED` environment variable:

bash

```bash
WASMCLOUD_OBSERVABILITY_ENABLED="true"
```

To enable only logs, use the `WASMCLOUD_LOGS_ENABLED` environment variable:

bash

```bash
WASMCLOUD_LOGS_ENABLED="true"
```

Enabling OTEL signals automatically structures logs for OTEL export. (In this case, local `stderr` logs remain plaintext.)

wasmCloud hosts export structured logs via HTTP/OpenTelemetry Protocol (`otlp`) on port 4318.

The endpoint for exports may be overwritten with the `OTEL_EXPORTER_OTLP_ENDPOINT` environment variable:

bash

```bash
OTEL_EXPORTER_OTLP_ENDPOINT=http://my-custom-host:4318
```

See the [host config](https://wasmcloud.com/docs/v1/cli/wasmcloud/) options for equivalent host configuration CLI flags.

### Log levels

The wasmCloud host supports the following log levels:

- `error`
- `warn`
- `info` (default)
- `debug`
- `trace`

To override the log level, use the `--log-level` [host config](https://wasmcloud.com/docs/v1/cli/wasmcloud/) argument.

> **Warning**
>
> Take care when enabling `trace` or `debug` level logs in a production environment. These log levels may contain sensitive information.

### Structured logs

In a production environment, it's more common to emit logs in a structured format and aggregate logs from all hosts in a centralized location. Enabling OTEL signals automatically structures JSON logs for OTEL export, while local `stderr` logs remain plaintext.

To enable structured log output *without* enabling OTEL signals, use the `--enable-structured-logging` [host config](https://wasmcloud.com/docs/v1/cli/wasmcloud/) argument (or set the `WASMCLOUD_STRUCTURED_LOGGING_ENABLED` environment variable). This will cause the host to emit logs as JSON, which are suitable for forwarding to a log aggregator.

json

```json
{
  "timestamp": "2024-01-09T17:54:59.113161Z",
  "level": "INFO",
  "fields": {
    "message": "wasmCloud host started",
    "host_id": "NDBYMWNPI3GSXBNM6H4WG6JTVB7K42KQWPOPICMIBVUXQL36ISJZHK4D"
  },
  "target": "wasmcloud_host::wasmbus"
}
```

### Viewing logs with Grafana and Loki

A set of sample configurations and Docker Compose files are available to help launch a local observability environment. After following the instructions to [**launch a wasmCloud observability ecosystem**](https://wasmcloud.com/docs/v1/deployment/observability/observability-with-opentelemetry/#launch-a-wasmcloud-observability-ecosystem), you can navigate to [http://localhost:5050/explore](http://localhost:5050/explore), click the dropdown in the upper left, and select **"Loki"** to view logs.

Refer to the environment variables in the [Docker Compose file](https://github.com/wasmCloud/wasmCloud/blob/main/examples/docker/docker-compose-otel.yml) for a complete example configuration. The example uses Grafana and Loki, but wasmCloud works with any OTEL-compatible backend.

Last updated on **Jun 10, 2026** by **Liam Randall**
