cloudflare/cloudflared · error

unable to create a new logfile: %s

Error message

unable to create a new logfile: %s

What it means

Logger setup failure in createDirFile: after ensuring the directory exists, os.OpenFile could not open (create/append) the logfile at Dirname/Filename with the configured file mode — typically permission denied, the path is a directory, or the disk is full. File logging cannot proceed.

Source

Thrown at logger/create.go:251

	return singleFileInit.writer, singleFileInit.creationError
}

func createDirFile(config FileConfig) (io.Writer, error) {
	if config.Dirname != "" {
		err := os.MkdirAll(config.Dirname, dirPermMode)

		if err != nil {
			return nil, fmt.Errorf("unable to create directories for new logfile: %s", err)
		}
	}

	mode := os.FileMode(filePermMode)

	fullPath := filepath.Join(config.Dirname, config.Filename)
	logFile, err := os.OpenFile(fullPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, mode)
	if err != nil {
		return nil, fmt.Errorf("unable to create a new logfile: %s", err)
	}

	return logFile, nil
}

func createRollingLogger(config RollingConfig) (io.Writer, error) {
	rotatingFileInit.once.Do(func() {
		if err := os.MkdirAll(config.Dirname, dirPermMode); err != nil {
			rotatingFileInit.creationError = err
			return
		}

		rotatingFileInit.writer = &lumberjack.Logger{
			Filename:   filepath.Join(config.Dirname, config.Filename),
			MaxBackups: config.maxBackups,
			MaxSize:    config.maxSize,
			MaxAge:     config.maxAge,
		}

View on GitHub (pinned to 2253eeeb25)

Solutions

  1. Check write permission on the target logfile path for the running user.
  2. Ensure the filename does not collide with an existing directory.
  3. Free disk space or point logging at a writable volume.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at logger/create.go:251 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of cloudflare/cloudflared@2253eeeb25 (2026-09-06). Data as JSON: /api/errors/c8ccd4deeea7179e. Report an issue: GitHub.