Skip to content

Commit 04a7dbd

Browse files
committed
[docs] add config docs about logging
1 parent d6384bd commit 04a7dbd

File tree

2 files changed

+103
-2
lines changed

2 files changed

+103
-2
lines changed

docs/config/logging.md

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,105 @@
22
icon: material/script-text
33
---
44

5-
TODO
5+
Under the `logging` config option the logging behavior and locations can be
6+
configured.
7+
8+
## `access`
9+
<span class="badge badge-purple" title="Value Type">object</span>
10+
<span class="badge badge-green" title="If this option is required or optional">recommended</span>
11+
12+
Under the `access` option the http access log can be configured.
13+
14+
??? file "config.yaml"
15+
16+
```yaml
17+
logging:
18+
access:
19+
dir: /var/log/offa
20+
stderr: true
21+
```
22+
23+
The following options are available:
24+
25+
### `dir`
26+
<span class="badge badge-purple" title="Value Type">directory path</span>
27+
<span class="badge badge-green" title="If this option is required or optional">optional</span>
28+
29+
The `dir` option is used to configure the directory where the log file
30+
should be stored.
31+
If not set, OFFA will not log to file.
32+
33+
### `stderr`
34+
<span class="badge badge-purple" title="Value Type">boolean</span>
35+
<span class="badge badge-blue" title="Default Value">`false`</span>
36+
<span class="badge badge-green" title="If this option is required or optional">optional</span>
37+
38+
The `stderr` option indicates if OFFA logs to `stderr`.
39+
40+
## `internal`
41+
The `internal` option is used to configure logging for OFFA's internal
42+
logging, i.e. logging related to what OFFA does.
43+
44+
??? file "config.yaml"
45+
46+
```yaml
47+
logging:
48+
internal:
49+
dir: /var/log/offa
50+
stderr: true
51+
level: info
52+
smart:
53+
enabled: true
54+
dir: /var/log/offa/errors
55+
```
56+
57+
All configuration options from [`access`](#access) also can be used with
58+
`internal`.
59+
In additional the following options can be used:
60+
61+
### `level`
62+
<span class="badge badge-purple" title="Value Type">enum</span>
63+
<span class="badge badge-blue" title="Default Value">info</span>
64+
<span class="badge badge-green" title="If this option is required or optional">optional</span>
65+
66+
The `level` option sets the minimal log level that should be logged.
67+
68+
Valid values are:
69+
70+
- `trace`
71+
- `debug`
72+
- `info`
73+
- `warn` / `warning`
74+
- `error`
75+
- `fatal`
76+
- `panic`
77+
78+
### `smart`
79+
80+
Under the `smart` option 'smart' logging can be enabled and configured.
81+
Smart logging allows to have a higher (less verbose) log level set for
82+
general (internal) logging without loosing valuable debug information in
83+
case errors occure.
84+
85+
If smart logging is enabled, the general logs are still done with the level
86+
set through the [`level`](#level) option, but if an error occurs a special
87+
error log is created to a dedicated file. This dedicated error log contains
88+
all log entries - including all log levels, also levels that normally woud
89+
not be logged - for that particular request.
90+
91+
#### `enabled`
92+
<span class="badge badge-purple" title="Value Type">boolean</span>
93+
<span class="badge badge-blue" title="Default Value">`false`</span>
94+
<span class="badge badge-green" title="If this option is required or optional">optional</span>
95+
96+
The `enabled` option is used to enable smart logging.
97+
98+
#### `dir`
99+
<span class="badge badge-purple" title="Value Type">directory path</span>
100+
<span class="badge badge-blue" title="Default Value">same as the internal logging dir</span>
101+
<span class="badge badge-green" title="If this option is required or optional">optional</span>
102+
103+
The `dir` option is used to specify the directory where smart error log
104+
files should be stored.
105+
If not set and smart logging is enabled, smart error logs are placed in the
106+
same directory as the regular internal log file.

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ type loggingConf struct {
178178

179179
type internalLoggerConf struct {
180180
LoggerConf `yaml:",inline"`
181+
Level string `yaml:"level"`
181182
Smart smartLoggerConf `yaml:"smart"`
182183
}
183184

184185
// LoggerConf holds configuration related to logging
185186
type LoggerConf struct {
186187
Dir string `yaml:"dir"`
187188
StdErr bool `yaml:"stderr"`
188-
Level string `yaml:"level"`
189189
}
190190

191191
type smartLoggerConf struct {

0 commit comments

Comments
 (0)