---
title: log
summary: null
url: https://www.fastly.com/documentation/reference/vcl/statements/log
---

```
log(STRING message);
```

**Available in:** all subroutines

Emits a log message to Fastly's [real time logging](https://www.fastly.com/documentation/guides/integrations/logging/) system.

```vcl
log "syslog " + req.service_id + " logger-name :: client_ip=" + client.ip;
```

The `log` statement takes just one argument, a message string, but in order for Fastly to route the message correctly, it must be prefixed with `"syslog"`, followed by your service ID and the endpoint name, separated by spaces. The ID of the active service is available as the `req.service_id` variable, or you can hard code the service ID into the string if you choose to. After this metadata, add a double colon (`::`) to terminate the header. The rest of the string is sent to the logging endpoint as the log message.

After stripping the header from the message sent from VCL, an endpoint-specific header may be added by the Fastly logging system depending on the requirements of the log endpoint and how you have configured it.

There are no constraints on the format in which you can log. The most straightforward formats to construct in VCL are query strings, due to our native support for the format with functions such as `querystring.set`. Other common formats like CSV or structured HTTP headers may also be constructed by concatenating portions of strings. Some log endpoints may require more complex formats like JSON or XML; if constructing a string in one of these formats be aware of the need for escaping, and use functions like `json.escape` and `xml_escape`.

Log messages must be a single line. Newline characters in log messages will terminate the message.

For more information about logging from Fastly services, see our [guide to log integrations and best practices](https://www.fastly.com/documentation/guides/integrations/non-fastly-services/developer-guide-logging).

## Logging in Fastly Fiddle

The interactive examples in our developer site and blogs are powered by [Fastly Fiddle](https://www.fastly.com/documentation/reference/tools/fiddle). To help debug and inspect code when experimenting in Fiddle, we support logging from Fiddle code without any logger prefix:

```vcl
log "Hello from Fiddle!";
```

However, this log message would be discarded if sent by a normal service, because it lacks any service ID or destination log endpoint name.
