{"record":{"id":"daf1e0c3cb78e333","repo":"projectlombok/lombok","slug":"the-declaration-must-follow-the-pattern-loggerty","errorCode":null,"errorMessage":"The declaration must follow the pattern: [LoggerType ]LoggerFactoryType.loggerFactoryMethod(loggerFactoryMethodParams)[(loggerFactoryMethodParams)]","messagePattern":"The declaration must follow the pattern: \\[LoggerType \\]LoggerFactoryType\\.loggerFactoryMethod\\(loggerFactoryMethodParams\\)\\[\\(loggerFactoryMethodParams\\)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/core/lombok/core/configuration/LogDeclaration.java","lineNumber":55,"sourceCode":"\tprivate final TypeName loggerType;\n\tprivate final TypeName loggerFactoryType;\n\tprivate final IdentifierName loggerFactoryMethod;\n\tprivate final List<LogFactoryParameter> parametersWithoutTopic;\n\tprivate final List<LogFactoryParameter> parametersWithTopic;\n\t\n\tprivate LogDeclaration(TypeName loggerType, TypeName loggerFactoryType, IdentifierName loggerFactoryMethod, List<LogFactoryParameter> parametersWithoutTopic, List<LogFactoryParameter> parametersWithTopic) {\n\t\tthis.loggerType = loggerType;\n\t\tthis.loggerFactoryType = loggerFactoryType;\n\t\tthis.loggerFactoryMethod = loggerFactoryMethod;\n\t\tthis.parametersWithoutTopic = parametersWithoutTopic;\n\t\tthis.parametersWithTopic = parametersWithTopic;\n\t}\n\t\n\tpublic static LogDeclaration valueOf(String declaration) {\n\t\tif (declaration == null) return null;\n\t\t\n\t\tMatcher matcher = DECLARATION_PATTERN.matcher(declaration);\n\t\tif (!matcher.matches()) throw new IllegalArgumentException(\"The declaration must follow the pattern: [LoggerType ]LoggerFactoryType.loggerFactoryMethod(loggerFactoryMethodParams)[(loggerFactoryMethodParams)]\");\n\t\t\n\t\tTypeName loggerFactoryType = TypeName.valueOf(matcher.group(2));\n\t\tTypeName loggerType = TypeName.valueOf(matcher.group(1));\n\t\tif (loggerType == null) loggerType = loggerFactoryType;\n\t\tIdentifierName loggerFactoryMethod = IdentifierName.valueOf(matcher.group(3));\n\t\tList<List<LogFactoryParameter>> allParameters = parseParameters(matcher.group(4));\n\t\t\n\t\tList<LogFactoryParameter> parametersWithoutTopic = null;\n\t\tList<LogFactoryParameter> parametersWithTopic = null;\n\t\tfor (List<LogFactoryParameter> parameters: allParameters) {\n\t\t\tif (parameters.contains(LogFactoryParameter.TOPIC)) {\n\t\t\t\tif (parametersWithTopic != null) throw new IllegalArgumentException(\"There is more than one parameter definition that includes TOPIC: \" + parametersWithTopic + \" and \" + parameters);\n\t\t\t\tparametersWithTopic = parameters;\n\t\t\t} else {\n\t\t\t\tif (parametersWithoutTopic != null) throw new IllegalArgumentException(\"There is more than one parmaeter definition that does not include TOPIC: \" + parametersWithoutTopic + \" and \" + parameters);\n\t\t\t\tparametersWithoutTopic = parameters;\n\t\t\t}\n\t\t}","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/projectlombok/lombok/blob/6d6a3e9fec0a9555702561fbeb8eac836575116e/src/core/lombok/core/configuration/LogDeclaration.java#L37-L73","documentation":"LogDeclaration.valueOf parses the value of the custom logger-factory config key. The declaration string must match DECLARATION_PATTERN: an optional logger type, the factory type, the factory method, and its parameter list. Non-matching strings throw IllegalArgumentException.","triggerScenarios":"Calling LogDeclaration.valueOf (directly or via config parsing of a custom logger declaration) with a string that does not match the pattern, e.g. missing the factory method, missing parentheses, or malformed parameter lists.","commonSituations":"Configuring a custom logger in lombok.config with hand-written declarations like 'com.acme.LogFactory.create' (missing params), wrong ordering of type/method, or typos in the parameter section.","solutions":["Rewrite the declaration as [LoggerType ]LoggerFactoryType.loggerFactoryMethod(params), e.g. 'example.TestLogger example.TestLoggerFactory.createLogger(TOPIC)'.","Include the parentheses and a valid parameter list (TOPIC or TYPE parameters, comma-separated).","Verify the factory type and method names are fully qualified where required."],"exampleFix":"// before (lombok.config)\nlombok.log.customDeclaration = com.acme.LogFactory.create\n// after\nlombok.log.customDeclaration = com.acme.LogFactory.create(TOPIC)","handlingStrategy":"validation","validationCode":"boolean isValidLogDeclaration(String d) {\n  return d != null && d.matches(\"([\\\\w$.]+\\\\s+)?[\\\\w$.]+\\\\.[\\\\w$]+\\\\s*\\\\(([^()]*)\\\\)(?:\\\\s*\\\\(([^()]*)\\\\))?\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  LogDeclaration decl = LogDeclaration.valueOf(cfgValue);\n} catch (IllegalArgumentException e) {\n  // surface a config-parsing error with the required pattern from the message\n}","preventionTips":["Follow the exact pattern: [LoggerType ]LoggerFactoryType.method(params)[(params2)].","Always include the parentheses with a parameter list (use TOPIC or TYPE entries).","Test the declaration with a minimal project before committing lombok.config."],"tags":["lombok","configuration","logging","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"6d6a3e9fec0a9555702561fbeb8eac836575116e","analyzedAt":"2026-09-07T23:18:01.841Z","contentChangedAt":"2026-09-07T23:18:01.841Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}