router-for-me/CLIProxyAPI · error

logging: failed to create log directory: %w

Error message

logging: failed to create log directory: %w

What it means

Error "logging: failed to create log directory: %w" thrown in router-for-me/CLIProxyAPI.

Source

Thrown at internal/logging/global_logger.go:197

	}
	return logDir
}

// ConfigureLogOutput switches the global log destination between rotating files and stdout.
// When logsMaxTotalSizeMB > 0, a background cleaner removes the oldest log files in the logs directory
// until the total size is within the limit.
func ConfigureLogOutput(cfg *config.Config) error {
	SetupBaseLogger()

	writerMu.Lock()
	defer writerMu.Unlock()

	logDir := ResolveLogDirectory(cfg)

	protectedPath := ""
	if cfg.LoggingToFile {
		if err := os.MkdirAll(logDir, 0o755); err != nil {
			return fmt.Errorf("logging: failed to create log directory: %w", err)
		}
		if logWriter != nil {
			_ = logWriter.Close()
		}
		protectedPath = filepath.Join(logDir, "main.log")
		logWriter = &lumberjack.Logger{
			Filename:   protectedPath,
			MaxSize:    10,
			MaxBackups: 0,
			MaxAge:     0,
			Compress:   false,
		}
		log.SetOutput(logWriter)
	} else {
		if logWriter != nil {
			_ = logWriter.Close()
			logWriter = nil
		}

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Verify the log directory path is writable and parent directories exist.
  2. Check the wrapped error for permission failures and fix directory permissions.

When it happens

Trigger: Thrown at internal/logging/global_logger.go:197 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15). Data as JSON: /api/errors/8215c6ac9c9c7712. Report an issue: GitHub.