Skip to content

Commit d65cd56

Browse files
authored
Change default log configuration (#13088)
* Change default log configuration This PR changes the install page and the docker default logging configuration to match the suggested configuration that I repeatedly end up suggesting on issues. It further improves the logging configuration docs to recommend specific instructions for how to configure logs for posting to issues. Signed-off-by: Andrew Thornton <[email protected]> * Update docs/content/doc/advanced/logging-documentation.en-us.md
1 parent 1c523e2 commit d65cd56

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

docker/root/etc/templates/app.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ HOST = $DB_HOST
2929
NAME = $DB_NAME
3030
USER = $DB_USER
3131
PASSWD = $DB_PASSWD
32+
LOG_SQL = false
3233

3334
[indexer]
3435
ISSUE_INDEXER_PATH = /data/gitea/indexers/issues.bleve
@@ -44,6 +45,11 @@ REPOSITORY_AVATAR_UPLOAD_PATH = /data/gitea/repo-avatars
4445
PATH = /data/gitea/attachments
4546

4647
[log]
48+
MODE = console
49+
LEVEL = info
50+
REDIRECT_MACARON_LOG = true
51+
MACARON = console
52+
ROUTER = console
4753
ROOT_PATH = /data/gitea/log
4854

4955
[security]

docs/content/doc/advanced/logging-documentation.en-us.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,48 @@ messages. However, you could perhaps set this logger to work on `FATAL`.
290290
* `RECEIVERS`: Email addresses to send to.
291291
* `SUBJECT`: **Diagnostic message from Gitea**
292292

293-
## Default Configuration
293+
## Debugging problems
294294

295-
The default empty configuration is equivalent to:
295+
When submitting logs in Gitea issues it is often helpful to submit
296+
merged logs obtained by either by redirecting the console log to a file or
297+
copying and pasting it. To that end it is recommended to set your logging to:
298+
299+
```ini
300+
[database]
301+
LOG_SQL = false ; SQL logs are rarely helpful unless we specifically ask for them
302+
303+
...
304+
305+
[log]
306+
MODE = console
307+
LEVEL = debug ; please set the level to debug when we are debugging a problem
308+
REDIRECT_MACARON_LOG = true
309+
MACARON = console
310+
ROUTER = console
311+
COLORIZE = false ; this can be true if you can strip out the ansi coloring
312+
```
313+
314+
Sometimes it will be helpful get some specific `TRACE` level logging retricted
315+
to messages that match a specific `EXPRESSION`. Adjusting the `MODE` in the
316+
`[log]` section to `MODE = console,traceconsole` to add a new logger output
317+
`traceconsole` and then adding its corresponding section would be helpful:
318+
319+
```ini
320+
[log.traceconsole] ; traceconsole here is just a name
321+
MODE = console ; this is the output that the traceconsole writes to
322+
LEVEL = trace
323+
EXPRESSION = ; putting a string here will restrict this logger to logging only those messages that match this expression
324+
```
325+
326+
(It's worth noting that log messages that match the expression at or above debug
327+
level will get logged twice so don't worry about that.)
328+
329+
`STACKTRACE_LEVEL` should generally be left unconfigured (and hence kept at
330+
`none`). There are only very specific occasions when it useful.
331+
332+
## Empty Configuration
333+
334+
The empty configuration is equivalent to:
296335

297336
```ini
298337
[log]

routers/install.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
271271
cfg.Section("database").Key("SSL_MODE").SetValue(setting.Database.SSLMode)
272272
cfg.Section("database").Key("CHARSET").SetValue(setting.Database.Charset)
273273
cfg.Section("database").Key("PATH").SetValue(setting.Database.Path)
274+
cfg.Section("database").Key("LOG_SQL").SetValue("false") // LOG_SQL is rarely helpful
274275

275276
cfg.Section("").Key("APP_NAME").SetValue(form.AppName)
276277
cfg.Section("repository").Key("ROOT").SetValue(form.RepoRootPath)
@@ -330,9 +331,12 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
330331

331332
cfg.Section("session").Key("PROVIDER").SetValue("file")
332333

333-
cfg.Section("log").Key("MODE").SetValue("file")
334+
cfg.Section("log").Key("MODE").SetValue("console")
334335
cfg.Section("log").Key("LEVEL").SetValue(setting.LogLevel)
335336
cfg.Section("log").Key("ROOT_PATH").SetValue(form.LogRootPath)
337+
cfg.Section("log").Key("REDIRECT_MACARON_LOG").SetValue("true")
338+
cfg.Section("log").Key("MACARON").SetValue("console")
339+
cfg.Section("log").Key("ROUTER").SetValue("console")
336340

337341
cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")
338342
var secretKey string

0 commit comments

Comments
 (0)