[Logging] No log files written

Hi everybody,

I have a problem I try to figure out for some days now w/o success. Maybe I miss something. So hopefully you can give me some hints.

Here some facts first:

  • Gitea 1.21.3
  • Running in Docker on Ubuntu VM
  • Deployed via docker-compose (standalone)

Logging to the console is working → can be accessed e.g. via Portainer.
In addition I configured gitea via app.ini to also use logging to files to have more granular control over log levels etc.

Here the app.ini lines for logging

[log]
ROOT_PATH = /data/logs
MODE = file,console
LEVEL = Info
ENABLE_SSH_LOG = true
logger.router.MODE = ,
logger.xorm.MODE = db-file
logger.access.MODE = access-file

[log.db-file]
MODE = file
LEVEL = Info
STACKTRACE_LEVEL = Critical
FILE_NAME = db.log
FLAGS = date,time,medfile,shortfuncname,level

[log.access-file]
MODE = file
LEVEL = Info
STACKTRACE_LEVEL = Critical
FILE_NAME = access.log
FLAGS = date,time,medfile,shortfuncname,level

The logging root path is linked via bind-mount in the compose file to my commonly used docker logfile share (working with other containers w/o issues)

volumes:
      - data:/data
      - ./../_logs/gitea:/data/logs

When running the container I can verify that the bind mount is working

  • open terminal inside the container
  • go to /data/logs
  • touch test.txt
  • file is created and can be seen on the host file system

So it seems the bind is working and also permissions should be ok. Nevertheless gitea is not creating any log file in this directory.

Any ideas what I’m missing?

Thanks a lot in advance
Sebastian

Hi Sebastian,

I’m in front of a very similar case :

I’m trying to log my Gitea access into a log file. I’m running Gitea version1.21.3 from gitea/gitea:latest docker image.

In my docker compose file, I specified the environment variable:

        environment:
          ...
          - GITEA__log__MODE=file

and in the apa.ini file, I’ve got that section corresponding to logs.

    [log]
    MODE = file
    logger.access.MODE = file
    LEVEL = Debug
    ROOT_PATH = /log
    LOG_ROTATE = true
    DAILY_ROTATE = true
    MAX_DAYS = 7

It appears that these configs have an effect on Gitea, as from the administrator web interface, if I’m checking the configuration for the log section I can see :

    Activer la journalisation SQL
    Modèle de journal d'accès
    {{.Ctx.RemoteHost}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}" "{{.Ctx.Req.UserAgent}}"
    Logger: access
    {
      "file.access": {
        "BufferLen": 10000,
        "Colorize": false,
        "Expression": "",
        "Flags": "none",
        "Level": "debug",
        "Prefix": "",
        "StacktraceLevel": "none",
        "WriterOption": {
          "Compress": true,
          "CompressionLevel": -1,
          "DailyRotate": true,
          "FileName": "/log/access.log",
          "LogRotate": true,
          "MaxDays": 7,
          "MaxSize": 268435456
        },
        "WriterType": "file"
      }
    }
    Logger: default
    {
      "file": {
        "BufferLen": 10000,
        "Colorize": false,
        "Expression": "",
        "Flags": "stdflags",
        "Level": "debug",
        "Prefix": "",
        "StacktraceLevel": "none",
        "WriterOption": {
          "Compress": true,
          "CompressionLevel": -1,
          "DailyRotate": true,
          "FileName": "/log/gitea.log",
          "LogRotate": true,
          "MaxDays": 7,
          "MaxSize": 268435456
        },
        "WriterType": "file"
      }
    }
    Logger: router
    {
      "file": {
        "BufferLen": 10000,
        "Colorize": false,
        "Expression": "",
        "Flags": "stdflags",
        "Level": "debug",
        "Prefix": "",
        "StacktraceLevel": "none",
        "WriterOption": {
          "Compress": true,
          "CompressionLevel": -1,
          "DailyRotate": true,
          "FileName": "/log/gitea.log",
          "LogRotate": true,
          "MaxDays": 7,
          "MaxSize": 268435456
        },
        "WriterType": "file"
      }
    }
    Logger: xorm
    {
      "file": {
        "BufferLen": 10000,
        "Colorize": false,
        "Expression": "",
        "Flags": "stdflags",
        "Level": "debug",
        "Prefix": "",
        "StacktraceLevel": "none",
        "WriterOption": {
          "Compress": true,
          "CompressionLevel": -1,
          "DailyRotate": true,
          "FileName": "/log/gitea.log",
          "LogRotate": true,
          "MaxDays": 7,
          "MaxSize": 268435456
        },
        "WriterType": "file"
      }
    }

But none of the log files /log/gitea.log or /log/access.log are created, despite the directory is writable by the git user. If I’m creating the files using the touch command, they stay empty.

A last info, the /log directory is mounted by the docker compose on a docker volume

What did I do wrong?

All the best,

Eric