go-delve/delve · error
errLogstrWithoutLog
errLogstrWithoutLog
Error message
--log-output specified without --log
What it means
pkg/logflags.Setup validates logging options: --log-output selects which log categories to emit, but it only takes effect when logging is enabled with --log. Passing a non-empty logstr with logFlag=false returns errLogstrWithoutLog because the output selector would be silently ignored.
Source
Thrown at pkg/logflags/logflags.go:189
return
}
logger := rpcLogger(true)
logger.Warnf("Listening for remote connections (connections are not authenticated nor encrypted)")
}
func WriteError(msg string) {
if logOut != nil {
fmt.Fprintln(logOut, msg)
} else {
fmt.Fprintln(os.Stderr, msg)
}
}
func WriteCgoFlagsWarning() {
makeLogger(true, "layer", "dlv").Warn("CGO_CFLAGS already set, Cgo code could be optimized.")
}
var errLogstrWithoutLog = errors.New("--log-output specified without --log")
// Setup sets debugger flags based on the contents of logstr.
// If logDest is not empty logs will be redirected to the file descriptor or
// file path specified by logDest.
func Setup(logFlag bool, logstr, logDest string) error {
if logDest != "" {
n, err := strconv.Atoi(logDest)
if err == nil {
logOut = os.NewFile(uintptr(n), "delve-logs")
} else {
fh, err := os.Create(logDest)
if err != nil {
return fmt.Errorf("could not create log file: %v", err)
}
logOut = fh
}
}
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)View on GitHub (pinned to a23773e6c3)
Solutions
- Add the --log flag whenever --log-output is used
- If you only need logs to a file/pipe, pass --log together with --log-output and --log-dest
- Remove --log-output if verbose logging is not wanted
Example fix
// before dlv debug --log-output=debugger main.go // after dlv debug --log --log-output=debugger main.go
Defensive patterns
Strategy: validation
Validate before calling
if logOutput != "" && !logFlag {
return fmt.Errorf("--log-output requires --log")
}
err := logflags.Setup(logFlag, logstr, logDest) Try / catch
if err := logflags.Setup(logFlag, logstr, logDest); err != nil {
if errors.Is(err, logflags.ErrLogstrWithoutLog) /* or message match */ {
return fmt.Errorf("enable --log or drop --log-output: %w", err)
}
return err
} Prevention
- Always pair --log-output with --log in CLI wrappers and IDE launch configs
- Validate flag combinations before exec'ing dlv
- Use --log --log-dest=<file> when you need logs redirected to a file
When it happens
Trigger: Calling Setup(false, "debugger=1", "") or running dlv with --log-output=... but without --log.
Common situations: Command lines or launch configs that set log-output (copied from another invocation) while omitting --log; wrapper scripts that only partially forward logging flags.
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/667c459e7f1f5c93.
Report an issue: GitHub.