{"record":{"id":"667c459e7f1f5c93","repo":"go-delve/delve","slug":"errlogstrwithoutlog","errorCode":"errLogstrWithoutLog","errorMessage":"--log-output specified without --log","messagePattern":"--log-output specified without --log","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/logflags/logflags.go","lineNumber":189,"sourceCode":"\t\treturn\n\t}\n\tlogger := rpcLogger(true)\n\tlogger.Warnf(\"Listening for remote connections (connections are not authenticated nor encrypted)\")\n}\n\nfunc WriteError(msg string) {\n\tif logOut != nil {\n\t\tfmt.Fprintln(logOut, msg)\n\t} else {\n\t\tfmt.Fprintln(os.Stderr, msg)\n\t}\n}\n\nfunc WriteCgoFlagsWarning() {\n\tmakeLogger(true, \"layer\", \"dlv\").Warn(\"CGO_CFLAGS already set, Cgo code could be optimized.\")\n}\n\nvar errLogstrWithoutLog = errors.New(\"--log-output specified without --log\")\n\n// Setup sets debugger flags based on the contents of logstr.\n// If logDest is not empty logs will be redirected to the file descriptor or\n// file path specified by logDest.\nfunc Setup(logFlag bool, logstr, logDest string) error {\n\tif logDest != \"\" {\n\t\tn, err := strconv.Atoi(logDest)\n\t\tif err == nil {\n\t\t\tlogOut = os.NewFile(uintptr(n), \"delve-logs\")\n\t\t} else {\n\t\t\tfh, err := os.Create(logDest)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"could not create log file: %v\", err)\n\t\t\t}\n\t\t\tlogOut = fh\n\t\t}\n\t}\n\tlog.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/logflags/logflags.go#L171-L207","documentation":"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.","triggerScenarios":"Calling Setup(false, \"debugger=1\", \"\") or running dlv with --log-output=... but without --log.","commonSituations":"Command lines or launch configs that set log-output (copied from another invocation) while omitting --log; wrapper scripts that only partially forward logging flags.","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"],"exampleFix":"// before\ndlv debug --log-output=debugger main.go\n// after\ndlv debug --log --log-output=debugger main.go","handlingStrategy":"validation","validationCode":"if logOutput != \"\" && !logFlag {\n    return fmt.Errorf(\"--log-output requires --log\")\n}\nerr := logflags.Setup(logFlag, logstr, logDest)","typeGuard":null,"tryCatchPattern":"if err := logflags.Setup(logFlag, logstr, logDest); err != nil {\n    if errors.Is(err, logflags.ErrLogstrWithoutLog) /* or message match */ {\n        return fmt.Errorf(\"enable --log or drop --log-output: %w\", err)\n    }\n    return err\n}","preventionTips":["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"],"tags":["cli-flags","logging"],"backgroundTag":"flag-requires-companion-flag","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}