{"record":{"id":"dd960717361299ba","repo":"infiniflow/ragflow","slug":"failed-to-initialize-logger-err","errorCode":null,"errorMessage":"failed to initialize logger: {err}","messagePattern":"failed to initialize logger: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cmd/ragflow_server.go","lineNumber":264,"sourceCode":"\t}\n\n\t// Temporary logger initialization\n\tvar logFileName string\n\tvar serverName string\n\tif arguments.name != nil {\n\t\tserverName = *arguments.name\n\t} else {\n\t\tserverName = fmt.Sprintf(\"%s_server\", *arguments.mode)\n\t}\n\tlogFileName = fmt.Sprintf(\"%s.log\", serverName)\n\n\tlogLevel := \"info\"\n\tif arguments.debugLog {\n\t\tlogLevel = \"debug\"\n\t}\n\n\tif err = common.InitLogger(logLevel, common.FileOutput{Filename: logFileName, Path: \"logs\"}, serverName); err != nil {\n\t\tpanic(\"failed to initialize logger: \" + err.Error())\n\t}\n\n\t// Initialize configuration\n\tvar configPath string\n\tif arguments.configPath != nil {\n\t\tconfigPath = *arguments.configPath\n\t}\n\n\tif err = server.Init(configPath); err != nil {\n\t\tcommon.Error(\"Failed to initialize configuration\", err)\n\t\tos.Exit(1)\n\t}\n\n\tglobalConfig := server.GetConfig()\n\n\t// override default port if provided\n\tswitch *arguments.mode {\n\tcase \"api\":","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/cmd/ragflow_server.go#L246-L282","documentation":"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.","triggerScenarios":"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.","commonSituations":"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/.","solutions":["mkdir -p logs in the working directory of the server and ensure the process user owns or can write it (chown/chmod)","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/","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","Free disk space or relax read-only filesystem constraints if those are the reported cause"],"exampleFix":"# before\n$ ./ragflow_server  # panic: failed to initialize logger: ... logs/ragflow_server.log: permission denied\n\n# after\n$ mkdir -p logs && chmod u+w logs && ./ragflow_server","handlingStrategy":"validation","validationCode":"if [ ! -w logs ] 2>/dev/null || [ ! -d logs ]; then\n  mkdir -p logs && chmod u+w logs\nfi","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create logs/ in the Dockerfile and chown it to the runtime user","Mount a writable volume at the logs path in read-only-rootfs containers","Run a preflight check (mkdir -p logs && touch logs/.probe) in the entrypoint before exec'ing the server"],"tags":["go","logging","startup","filesystem","permissions","panic"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}