{"id":"4273c3cebcdbb438","repo":"gofiber/fiber","slug":"logger-unknown-template-tag","errorCode":null,"errorMessage":"logger: unknown template tag","messagePattern":"logger: unknown template tag","errorType":"exception","errorClass":"ErrUnknownTag","httpStatus":null,"severity":"error","filePath":"middleware/logger/errors.go","lineNumber":12,"sourceCode":"package logger\n\nimport (\n\t\"errors\"\n\t\"strconv\"\n\n\t\"github.com/gofiber/fiber/v3/internal/logtemplate\"\n)\n\n// ErrUnknownTag indicates that the logger middleware was configured with a\n// format that references a tag with no registered renderer.\nvar ErrUnknownTag = errors.New(\"logger: unknown template tag\")\n\n// UnknownTagError is the typed error panicked from New when Config.Format\n// references an unknown tag. Tag is the offending tag including any\n// parametric suffix; Param is the parameter portion when the tag was\n// parametric (empty for bare tags); Hint, when non-empty, is a human-\n// readable suggestion (e.g. parametric form for a likely-mistyped bare tag).\ntype UnknownTagError struct {\n\tTag   string\n\tParam string\n\tHint  string\n}\n\nfunc (e *UnknownTagError) Error() string {\n\tmsg := ErrUnknownTag.Error() + \": \" + strconv.Quote(e.Tag)\n\tif e.Hint != \"\" {\n\t\tmsg += \" (\" + e.Hint + \")\"\n\t}\n\treturn msg","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/gofiber/fiber/blob/9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c/middleware/logger/errors.go#L1-L30","documentation":"Returned/panicked by the logger middleware (errors.go:12) when Config.Format contains a placeholder tag that has no registered renderer. The middleware parses the format string at construction time (New) and builds a compiled template; an unknown tag produces an UnknownTagError (a typed error wrapping ErrUnknownTag) that is either returned from New or panicked, depending on how the logger is initialized. The error includes the offending tag name and an optional Hint.","triggerScenarios":"Configuring logger.Config.Format with a typo or unsupported tag, e.g. '${responesTime}' instead of '${latency}', or referencing a custom tag that was never registered via RegisterTag. The error surfaces at middleware construction (startup), not at request time.","commonSituations":"Typo in a tag name in the format string; referencing a tag from a newer/older version; forgetting to call RegisterTag for a custom tag before creating the logger; copy-pasting a format from documentation for a different version.","solutions":["Check the error's Tag field for the exact misspelled tag and correct it to a known tag (see the Tag* constants in logger/tags.go).","Register custom tags with logger.RegisterTag(name, fn) before calling logger.New().","Start with the default format and add tags incrementally to isolate the bad one."],"exampleFix":"// before\napp.Use(logger.New(logger.Config{\n  Format: \"${time} ${method} ${path} ${responesTime}\\n\", // typo\n}))\n// after\napp.Use(logger.New(logger.Config{\n  Format: \"${time} ${method} ${path} ${latency}\\n\",\n}))","handlingStrategy":"validation","validationCode":"// Before deploying, check all tags in your format string are known\nknownTags := map[string]bool{\"time\":true,\"method\":true,\"path\":true,\"status\":true,\"latency\":true,\"ip\":true}\n// parse ${...} tokens from your format and verify each is in knownTags or registered","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reference the Tag* constants in logger/tags.go when building format strings.","Register custom tags with RegisterTag before constructing the logger.","Add a startup test that constructs the logger with your format to catch typos early."],"tags":["logger","configuration","formatting","startup"],"analyzedSha":"9a4c7e57fe0b080a04235d28a4b0d2b4b353d58c","analyzedAt":"2026-08-04T21:44:03.395Z","schemaVersion":2}