{"record":{"id":"1c9428e8b2b53dd9","repo":"cloudflare/cloudflared","slug":"errmanagedlognotfound","errorCode":"ErrManagedLogNotFound","errorMessage":"managed log directory not found","messagePattern":"managed log directory not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"diagnostic/error.go","lineNumber":9,"sourceCode":"package diagnostic\n\nimport (\n\t\"errors\"\n)\n\nvar (\n\t// Error used when there is no log directory available.\n\tErrManagedLogNotFound = errors.New(\"managed log directory not found\")\n\t// Error used when it is not possible to collect logs using the log configuration.\n\tErrLogConfigurationIsInvalid = errors.New(\"provided log configuration is invalid\")\n\t// Error used when parsing the fields of the output of collector.\n\tErrInsufficientLines = errors.New(\"insufficient lines\")\n\t// Error used when parsing the lines of the output of collector.\n\tErrInsuficientFields = errors.New(\"insufficient fields\")\n\t// Error used when given key is not found while parsing KV.\n\tErrKeyNotFound = errors.New(\"key not found\")\n\t// Error used when there is no disk volume information available.\n\tErrNoVolumeFound = errors.New(\"no disk volume information found\")\n\t// Error user when the base url of the diagnostic client is not provided.\n\tErrNoBaseURL = errors.New(\"no base url\")\n\t// Error used when no metrics server is found listening to the known addresses list (check [metrics.GetMetricsKnownAddresses]).\n\tErrMetricsServerNotFound = errors.New(\"metrics server not found\")\n\t// Error used when multiple metrics server are found listening to the known addresses list (check [metrics.GetMetricsKnownAddresses]).\n\tErrMultipleMetricsServerFound = errors.New(\"multiple metrics server found\")\n\t// Error used when a temporary file creation fails within the diagnostic procedure\n\tErrCreatingTemporaryFile = errors.New(\"temporary file creation failed\")","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/diagnostic/error.go#L1-L27","documentation":"ErrManagedLogNotFound is returned by getServiceLogPath (diagnostic/log_collector_host.go) when the cloudflared managed log directory cannot be located on the host. The collector probes well-known per-OS paths (e.g. darwinManagedLogsPath on macOS, the user home fallback, and platform-specific locations on Linux/Windows); when none of them exists, it gives up with this sentinel error instead of returning an empty path. It means log collection via the diagnostics subsystem cannot proceed because there is no managed log directory to read from.","triggerScenarios":"Calling LogCollector.Collect (host collector) when: (1) on macOS, darwinManagedLogsPath does not exist per os.Stat and the home-directory fallback directory is also missing; (2) the runtime.GOOS switch in getServiceLogPath hits its default branch (unsupported/unknown platform) — the exact `return \"\", ErrManagedLogNotFound` at diagnostic/log_collector_host.go:70; (3) cloudflared was never run as a managed service so it never created the log directory.","commonSituations":"Running `cloudflared tunnel` diagnostics (cloudflared diag) on a machine where cloudflared runs manually in the foreground rather than as a service, so no managed log dir exists; running in a container where log directories are not mounted; invoking diagnostics on an OS not covered by the getServiceLogPath switch; a fresh install where the service has never started.","solutions":["Verify cloudflared is running as a managed service (or has run at least once) so the platform log directory was created; start the service first, then re-run diagnostics.","Check the expected log directory for your OS exists (e.g. macOS: the darwinManagedLogsPath under the user home) and create/recreate it by restarting the service if it was deleted.","If running in a containerized environment, pass --diag-container-id (or --diag-pod-id in Kubernetes) so logs are collected from the container instead of the host paths.","If you do not need log collection, disable it with --no-diag-logs so the collector is not invoked at all.","If your platform hits the default branch of getServiceLogPath, confirm you are on a supported OS/version of cloudflared; upgrade cloudflared if support for your platform is newer."],"exampleFix":"// before: unconditional log collection in a shell script\ncloudflared diag --output out.zip\n\n// after: skip log collection when there is no managed log dir\nif [ -d \"$HOME/.cloudflared/logs\" ]; then\n  cloudflared diag --output out.zip\nelse\n  cloudflared diag --output out.zip --no-diag-logs\nfi","handlingStrategy":"fallback","validationCode":"// Go: check the expected managed log dir before collecting\nif _, err := os.Stat(logDir); os.IsNotExist(err) {\n    // skip log collection or use container targeting flags\n}","typeGuard":"func managedLogDirExists(dir string) bool {\n    fi, err := os.Stat(dir)\n    return err == nil && fi.IsDir()\n}","tryCatchPattern":"path, err := collector.Collect(ctx)\nif errors.Is(err, diagnostic.ErrManagedLogNotFound) {\n    log.Info().Msg(\"no managed log directory; skipping log collection\")\n    return nil // degrade gracefully\n}","preventionTips":["Run cloudflared as a managed service so the log directory is created before invoking diagnostics.","In containers, always pass --diag-container-id/--diag-pod-id instead of relying on host log paths.","Use --no-diag-logs when log collection is not needed.","Gate log collection on os.Stat of the expected directory for the current GOOS."],"tags":["diagnostics","logs","filesystem","cloudflared"],"backgroundTag":"directory-not-found","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}