---
title: "Logging API"
description: "Logging conventions within Haraka"
canonical_url: "https://haraka.github.io/core/Logging_API"
---
# Logging API

> Logging conventions within Haraka

Logging conventions within Haraka

## See also

[https://github.com/haraka/Haraka/pull/119]()

logline will always always be in the form:

```text
[level] [connection uuid] [origin] message
```

where origin is "haraka_core" or the name of the plugin which
triggered the message, and "connection uuid" is the ID of the
connection associated with the message.

when calling a log method on logger, you should provide the
plugin object and the connection object anywhere in the arguments
to the log method.

```js
logger.logdebug("i like turtles", plugin, connection);
```

will yield, for example,

```text
[DEBUG] [7F1C820F-DC79-4192-9AA6-5307354B20A6] [dnsbl] i like turtles
```

if you call the log method on the connection object, you can
forego the connection as argument:

```js
connection.logdebug("turtles all the way down", plugin);
```

and similarly for the log methods on the plugin object:

```js
plugin.logdebug("he just really likes turtles", connection);
```

failing to provide a connection and/or plugin object will leave
the default values in the log (currently "core" and
"no_connection").

this is implemented by testing for argument type in
the logger.js log* method. objects-as-arguments are then sniffed
to try to determine if they're a connection or plugin instance.


## Sitemap

See the full [sitemap](https://haraka.github.io/sitemap.md) for all pages.
