{"record":{"id":"33968af2eee2a8a5","repo":"cloudflare/cloudflared","slug":"unable-to-create-directories-for-new-logfile-s","errorCode":null,"errorMessage":"unable to create directories for new logfile: %s","messagePattern":"unable to create directories for new logfile: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"logger/create.go","lineNumber":242,"sourceCode":"\t\t\t// If creating a new logfile fails, then we have no choice but to error out.\n\t\t\tif err != nil {\n\t\t\t\tsingleFileInit.creationError = err\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tsingleFileInit.writer = logFile\n\t})\n\n\treturn singleFileInit.writer, singleFileInit.creationError\n}\n\nfunc createDirFile(config FileConfig) (io.Writer, error) {\n\tif config.Dirname != \"\" {\n\t\terr := os.MkdirAll(config.Dirname, dirPermMode)\n\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to create directories for new logfile: %s\", err)\n\t\t}\n\t}\n\n\tmode := os.FileMode(filePermMode)\n\n\tfullPath := filepath.Join(config.Dirname, config.Filename)\n\tlogFile, err := os.OpenFile(fullPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, mode)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create a new logfile: %s\", err)\n\t}\n\n\treturn logFile, nil\n}\n\nfunc createRollingLogger(config RollingConfig) (io.Writer, error) {\n\trotatingFileInit.once.Do(func() {\n\t\tif err := os.MkdirAll(config.Dirname, dirPermMode); err != nil {\n\t\t\trotatingFileInit.creationError = err","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/logger/create.go#L224-L260","documentation":"Logger setup failure in createDirFile: os.MkdirAll could not create the configured FileConfig.Dirname directory for a new logfile (bad path component, permission denied, or path exists as a file). File logging cannot start, so the error is stored and surfaced to the caller configuring the logger.","triggerScenarios":"Thrown at logger/create.go:242 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the configured directory path is valid and its parents are writable by the cloudflared process.","Check filesystem permissions or run with appropriate privileges/uid.","Correct the log directory in configuration (e.g. --logfile or LogDirectory settings)."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}