infiniflow/ragflow · critical

failed to initialize logger: {err}

Error message

failed to initialize logger: {err}

What it means

This panic fires in the ragflow_server main entrypoint when common.InitLogger cannot set up the file logger for <serverName>.log under the logs/ directory. Logger initialization is treated as a hard startup dependency, so any failure (unwritable path, missing directory, permission denied, disk full) aborts the process immediately with the underlying error appended to the message.

Source

Thrown at cmd/ragflow_server.go:264

	}

	// Temporary logger initialization
	var logFileName string
	var serverName string
	if arguments.name != nil {
		serverName = *arguments.name
	} else {
		serverName = fmt.Sprintf("%s_server", *arguments.mode)
	}
	logFileName = fmt.Sprintf("%s.log", serverName)

	logLevel := "info"
	if arguments.debugLog {
		logLevel = "debug"
	}

	if err = common.InitLogger(logLevel, common.FileOutput{Filename: logFileName, Path: "logs"}, serverName); err != nil {
		panic("failed to initialize logger: " + err.Error())
	}

	// Initialize configuration
	var configPath string
	if arguments.configPath != nil {
		configPath = *arguments.configPath
	}

	if err = server.Init(configPath); err != nil {
		common.Error("Failed to initialize configuration", err)
		os.Exit(1)
	}

	globalConfig := server.GetConfig()

	// override default port if provided
	switch *arguments.mode {
	case "api":

View on GitHub (pinned to 554fb1133a)

Solutions

  1. mkdir -p logs in the working directory of the server and ensure the process user owns or can write it (chown/chmod)
  2. If running in a container, mount a writable volume (e.g. emptyDir) at the logs path or set the working directory to one that contains a writable logs/
  3. Check the err text appended to the panic for the exact OS cause (permission denied, read-only file system, no space left on device) and address that
  4. Free disk space or relax read-only filesystem constraints if those are the reported cause

Example fix

# before
$ ./ragflow_server  # panic: failed to initialize logger: ... logs/ragflow_server.log: permission denied

# after
$ mkdir -p logs && chmod u+w logs && ./ragflow_server
Defensive patterns

Strategy: validation

Validate before calling

if [ ! -w logs ] 2>/dev/null || [ ! -d logs ]; then
  mkdir -p logs && chmod u+w logs
fi

Prevention

When it happens

Trigger: Starting ragflow_server (any mode) when the logs/ directory does not exist or is not writable by the process user; running the binary from a read-only working directory; disk full or filesystem error when creating/truncating <mode>_server.log; passing a server name via --name that yields an invalid filename on the target OS.

Common situations: Container images running as a non-root user without write access to /ragflow/logs; launching the binary from a directory other than the repo root where logs/ was never created; readOnlyRootFilesystem in Kubernetes without an emptyDir mounted at logs/.

Related errors


AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15). Data as JSON: /api/errors/dd960717361299ba. Report an issue: GitHub.