{"id":"fbdc0a38456afbdb","repo":"labstack/echo","slug":"missing-logvaluesfunc-callback-function-for-reques","errorCode":null,"errorMessage":"missing LogValuesFunc callback function for request logger middleware","messagePattern":"missing LogValuesFunc callback function for request logger middleware","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"middleware/request_logger.go","lineNumber":256,"sourceCode":"\tmw, err := config.ToMiddleware()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn mw\n}\n\n// ToMiddleware converts RequestLoggerConfig into middleware or returns an error for invalid configuration.\nfunc (config RequestLoggerConfig) ToMiddleware() (echo.MiddlewareFunc, error) {\n\tif config.Skipper == nil {\n\t\tconfig.Skipper = DefaultSkipper\n\t}\n\tnow := time.Now\n\tif config.timeNow != nil {\n\t\tnow = config.timeNow\n\t}\n\n\tif config.LogValuesFunc == nil {\n\t\treturn nil, errors.New(\"missing LogValuesFunc callback function for request logger middleware\")\n\t}\n\n\tlogHeaders := len(config.LogHeaders) > 0\n\theaders := append([]string(nil), config.LogHeaders...)\n\tfor i, v := range headers {\n\t\theaders[i] = http.CanonicalHeaderKey(v)\n\t}\n\n\tlogQueryParams := len(config.LogQueryParams) > 0\n\tlogFormValues := len(config.LogFormValues) > 0\n\n\treturn func(next echo.HandlerFunc) echo.HandlerFunc {\n\t\treturn func(c *echo.Context) error {\n\t\t\tif config.Skipper(c) {\n\t\t\t\treturn next(c)\n\t\t\t}\n\n\t\t\treq := c.Request()","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/labstack/echo/blob/05489dc1730161df26b72d1ae2a3ba6fb8178fc7/middleware/request_logger.go#L238-L274","documentation":"Returned by RequestLoggerConfig.ToMiddleware when config.LogValuesFunc is nil. This callback is the whole point of RequestLogger — it receives the extracted RequestLoggerValues so you can emit them to your logger (slog, zap, zerolog, etc.). Without it there is nowhere to send the captured data. The parameterless RequestLogger() provides a default callback, so only WithConfig without the field triggers this.","triggerScenarios":"Calling RequestLoggerWithConfig(RequestLoggerConfig{LogStatus: true, LogURI: true}) without setting LogValuesFunc.","commonSituations":"Developer enables Log* flags but forgets the callback; or assumes the middleware logs to stdout by default like the legacy Logger middleware (it does not — you must supply LogValuesFunc or use RequestLogger()).","solutions":["Set LogValuesFunc to a function that writes v to your logger (see the package-level examples for slog/zap/zerolog/logrus).","If you just want default logging via echo.Context.Logger(), use the parameterless RequestLogger() which wires a default callback.","Use config.ToMiddleware() to receive the error instead of panicking."],"exampleFix":"// before\nm := middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{\n    LogStatus: true,\n    LogURI:    true,\n})\n// after\nm := middleware.RequestLoggerWithConfig(middleware.RequestLoggerConfig{\n    LogStatus: true,\n    LogURI:    true,\n    LogValuesFunc: func(c *echo.Context, v middleware.RequestLoggerValues) error {\n        c.Logger().Info(\"request\", \"uri\", v.URI, \"status\", v.Status)\n        return nil\n    },\n})","handlingStrategy":"validation","validationCode":"func requestLoggerMiddleware(logValues func(*echo.Context, middleware.RequestLoggerValues) error) (echo.MiddlewareFunc, error) {\n    cfg := middleware.RequestLoggerConfig{LogStatus: true, LogURI: true, LogValuesFunc: logValues}\n    if cfg.LogValuesFunc == nil {\n        return nil, errors.New(\"RequestLogger requires LogValuesFunc\")\n    }\n    return cfg.ToMiddleware()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set LogValuesFunc when using RequestLoggerWithConfig; it is the only place captured values go.","If you just want default logging, use the parameterless RequestLogger().","Copy from the package-level slog/zap/zerolog examples to avoid a no-op callback."],"tags":["middleware","request-logger","logging","config","panic","startup"],"analyzedSha":"05489dc1730161df26b72d1ae2a3ba6fb8178fc7","analyzedAt":"2026-08-04T21:32:47.783Z","schemaVersion":2}