summaryrefslogtreecommitdiff
path: root/docs/content/configuration/miscellaneous/logging.md
blob: 0865e003c2426a81b04a83f57fe2e0cb1a5069a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---
title: "Log"
description: "Configuring the Log Settings."
summary: "Authelia performs logging to various locations. This section describes how to configure and tune this."
date: 2021-06-01T14:09:50+10:00
draft: false
images: []
weight: 199400
toc: true
aliases:
  - /docs/configuration/logging.html
seo:
  title: "" # custom title (optional)
  description: "" # custom description (recommended)
  canonical: "" # custom canonical URL (optional)
  noindex: false # false (default) or true
---

The logging section tunes the logging settings.

## Configuration

{{< config-alert-example >}}

```yaml {title="configuration.yml"}
log:
  level: 'info'
  format: 'text'
  file_path: ''
  keep_stdout: false
```

## Options

This section describes the individual configuration options.

### level

{{< confkey type="string" default="info" required="no" >}}

Defines the level of logs used by Authelia. This level can be set to `trace`, `debug`, `info`, `warn`, or `error`. When
setting level to `trace`, you will generate a large amount of log entries and expose the `/debug/vars` and
`/debug/pprof/` endpoints which should not be enabled in production.

```yaml {title="configuration.yml"}
log:
  level: 'debug'
```

### format

{{< confkey type="string" default="text" required="no" >}}

Defines the format of the logs written by Authelia. This format can be set to `json` or `text`.

```yaml {title="configuration.yml"}
log:
  format: 'json'
```

#### JSON format

```json
{"level":"info","msg":"Logging severity set to info","time":"2020-01-01T00:00:00+11:00"}
{"level":"info","msg":"Authelia is listening for non-TLS connections on 0.0.0.0:{{< sitevar name="port" nojs="9091" >}}","time":"2020-01-01T00:00:00+11:00"}
```

#### Text format

```text
time="2020-01-01T00:00:00+11:00" level=info msg="Logging severity set to info"
time="2020-01-01T00:00:00+11:00" level=info msg="Authelia is listening for non-TLS connections on 0.0.0.0:{{< sitevar name="port" nojs="9091" >}}"
```

### file_path

{{< confkey type="string" required="no" >}}

Logs can be stored in a file when file path is provided. Otherwise logs are written to standard output. When setting the
level to `debug` or `trace` this will generate large amount of log entries. Administrators will need to ensure that
they rotate and/or truncate the logs over time to prevent significant long-term disk usage.

There are two replacements that exist in this string for the purpose of including the date. The `%d` value which just
uses the [RFC3339] layout, and the `{datetime}` replacement which by
default uses the [RFC3339] layout, but optionally can be suffixed with the
[Go Layout](https://pkg.go.dev/time#pkg-constants) semantics in the format of `{datetime:<layout>}` where `<layout>` is
the layout supported by Go.

When using a log file sending the Authelia process a SIGHUP will cause it to close and reopen the current log file and
truncate it. This is useful for log rotation services which can force a reopen so the file descriptor open does not
continue to append to the old log file.

#### File Path Examples

__Standard Example:__

```yaml {title="configuration.yml"}
log:
  file_path: '/config/authelia.log'
```

__Date Time Example:__

```yaml {title="configuration.yml"}
log:
  file_path: '/config/authelia.%d.log'
```

__Date Time Example (with custom layout):__

```yaml {title="configuration.yml"}
log:
  file_path: '/config/authelia.{datetime:Mon Jan 2 15:04:05 MST 2006}.log'
```

### keep_stdout

{{< confkey type="boolean" default="false" required="no" >}}

Overrides the behavior to redirect logging only to the `file_path`. If set to `true` logs will be written to both
standard output, and the defined logging location.

```yaml {title="configuration.yml"}
log:
  keep_stdout: true
```

[RFC3339]: https://datatracker.ietf.org/doc/html/rfc3339