---
title: Manage InfluxDB logs
description: Learn how to configure, manage, and process your InfluxDB logs.
url: https://docs.influxdata.com/influxdb/v2/admin/logs/
estimated_tokens: 1812
product: InfluxDB OSS v2
version: v2
publisher: InfluxData
canonical: https://docs.influxdata.com/influxdb/v2/admin/logs/
date: '2023-11-06T15:53:12-07:00'
lastmod: '2023-11-06T15:53:12-07:00'
---

This page documents an earlier version of InfluxDB OSS.[InfluxDB 3 Core](/influxdb3/core/) is the latest stable version.

#### API token hashing is enabled by default in InfluxDB OSS 2.9.0

Stronger token security: tokens are stored as hashes on disk, so a
copy of the database file doesn’t expose usable tokens. Existing
tokens are hashed on first startup and the original strings can’t
be recovered afterward — **capture any plaintext tokens you still
need before you upgrade**.

For more information, see [Token hashing](/influxdb/v2/admin/tokens/#token-hashing).

Learn how to configure, manage, and process your InfluxDB logs:

* [Configure your InfluxDB log location](#configure-your-influxdb-log-location)
* [Configure your log level](#configure-your-log-level)
* [Enable the Flux query log](#enable-the-flux-query-log)
* [Use external tools to manage and process logs](#use-external-tools-to-manage-and-process-logs)
* [Log formats](#log-formats)

## Configure your InfluxDB log location

By default, InfluxDB outputs all logs to **stdout**. To view InfluxDB logs,
view the output of the [`influxd`](/influxdb/v2/reference/cli/influxd/) process.

* [Write logs to a file](#write-logs-to-a-file)
* [Logs when running InfluxDB as a service](#logs-when-running-influxdb-as-a-service)

### Write logs to a file

To write InfluxDB logs to a file, redirect **stdout** to a file when starting
the InfluxDB service ([`influxd`](/influxdb/v2/reference/cli/influxd/)).

```sh
influxd 1> /path/to/influxdb.log
```

> [!Note]
> When logging to a file, InfluxDB uses the [logfmt](#logfmt) format.

### Logs when running InfluxDB as a service

If you use a service manager to run InfluxDB, the service manager determines the location of logs.

#### systemd ####

Most Linux systems direct logs to the `systemd` journal.
To access these logs, use the following command:

```sh
sudo journalctl -u influxdb.service
```

For more information, see the [journald.conf documentation](https://www.freedesktop.org/software/systemd/man/journald.conf.html).

When InfluxDB is run as a service, **stdout** is discarded by default (sent to `/dev/null`).
To write logs to a file:

1. Open the InfluxDB startup script (`/etc/default/influxdb`) in a text editor.

2. Set the `STDOUT` environment variable to the path where you want to store
   the InfluxDB logs. For example:

   ```
   STDOUT=/var/log/influxdb/influxd.log
   ```

3. Save the changes to the startup script.

4. Restart the InfluxDB service to apply the changes.

   ```
   service influxdb restart
   ```

## Configure your log level

Use the [`log-level` InfluxDB configuration option](/influxdb/v2/reference/config-options/#log-level)to specify the log levels the InfluxDB service outputs.
InfluxDB supports the following log levels:

* **debug**: Output logs with debug, info, and error log levels.
* **info**: *(Default)* Output logs with info and error log levels.
* **error**: Output logs with the error log level only.

#### influxd flag ####

```sh
influxd --log-level=info
```

```sh
export INFLUXD_LOG_LEVEL=info
```

#### YAML ####

```yml
log-level: info
```

```toml
log-level = "info"
```

```json
{
  "log-level": "info"
}
```

*For information about configuring InfluxDB, see [InfluxDB configuration options](/influxdb/v2/reference/config-options/).*

## Enable the Flux query log

Use the [`flux-log-enabled` configuration option](/influxdb/v2/reference/config-options/#flux-log-enabled)to enable Flux query logging. InfluxDB outputs Flux query logs to **stdout**with all other InfluxDB logs.

#### influxd flag ####

```sh
influxd --flux-log-enabled
```

```sh
export INFLUXD_FLUX_LOG_ENABLED=true
```

#### YAML ####

```yml
flux-log-enabled: true
```

```toml
flux-log-enabled = true
```

```json
{
  "flux-log-enabled": true
}
```

*For information about configuring InfluxDB, see [InfluxDB configuration options](/influxdb/v2/reference/config-options/).*

## Use external tools to manage and process logs

Use the following popular tools to manage and process InfluxDB logs:

### logrotate

[logrotate](https://github.com/logrotate/logrotate) simplifies the
administration of log files and provides automatic rotation compression, removal
and mailing of log files. Logrotate can be set to handle a log file hourly,
daily, weekly, monthly or when the log file gets to a certain size.

### hutils

[hutils](https://blog.heroku.com/hutils-explore-your-structured-data-logs) is a
collection of command line utilities for working with logs with [logfmt](#logfmt)encoding, including:

* **lcut**: Extracts values from a logfmt trace based on a specified field name.
* **lfmt**: Reformats and highlights key sections of logfmt lines.
* **ltap**: Accesses messages from log providers in a consistent way to allow
  easy parsing by other utilities that operate on logfmt traces.
* **lviz**: Visualizes logfmt output by building a tree out of a dataset
  combining common sets of key-value pairs into shared parent nodes.

### lnav (Log File Navigator)

[lnav (Log File Navigator)](http://lnav.org/) is an advanced log file viewer useful for watching
and analyzing log files from a terminal.
The lnav viewer provides a single log view, automatic log format detection,
filtering, timeline view, pretty-print view, and querying logs using SQL.

## Log formats

InfluxDB outputs logs in one of two formats depending on the location of where
logs are output.

* [Console/TTY](#consoletty)
* [logfmt](#logfmt)

### Console/TTY

**When logging to a terminal or other TTY devices**, InfluxDB uses a console-friendly format.

##### Example console/TTY format

```sh
2022-09-29T21:58:29.936355Z	info	Welcome to InfluxDB	{"log_id": "0dEoz3C0000", "version": "dev", "commit": "663d43d210", "build_date": "2022-09-29T21:58:29Z", "log_level": "info"}
2022-09-29T21:58:29.977671Z	info	Resources opened	{"log_id": "0dEoz3C0000", "service": "bolt", "path": "/Users/exampleuser/.influxdbv2/influxd.bolt"}
2022-09-29T21:58:29.977891Z	info	Resources opened	{"log_id": "0dEoz3C0000", "service": "sqlite", "path": "/Users/exampleuser/.influxdbv2/influxd.sqlite"}
2022-09-29T21:58:30.059709Z	info	Checking InfluxDB metadata for prior version.	{"log_id": "0dEoz3C0000", "bolt_path": "/Users/exampleuser/.influxdbv2/influxd.bolt"}
```

### logfmt

**When logging to a file**, InfluxDB uses **logfmt**, a machine-readable
structured log format that provides simpler integrations with external tools like[Splunk](https://www.splunk.com/), [Papertrail](https://www.papertrail.com/),[Elasticsearch](https://www.elastic.co/), and other third party tools.

##### Example logfmt format

```sh
ts=2022-09-29T16:54:16.021427Z lvl=info msg="Welcome to InfluxDB" log_id=0dEYZvqG000 version=dev commit=663d43d210 build_date=2022-09-29T16:54:15Z log_level=info
ts=2022-09-29T16:54:16.062239Z lvl=info msg="Resources opened" log_id=0dEYZvqG000 service=bolt path=/Users/exampleuser/.influxdbv2/influxd.bolt
ts=2022-09-29T16:54:16.062457Z lvl=info msg="Resources opened" log_id=0dEYZvqG000 service=sqlite path=/Users/exampleuser/.influxdbv2/influxd.sqlite
ts=2022-09-29T16:54:16.144430Z lvl=info msg="Checking InfluxDB metadata for prior version." log_id=0dEYZvqG000 bolt_path=/Users/exampleuser/.influxdbv2/influxd.bolt
```
