projectlombok/lombok · error · IllegalArgumentException

The declaration must follow the pattern: [LoggerType…

Error message

The declaration must follow the pattern: [LoggerType ]LoggerFactoryType.loggerFactoryMethod(loggerFactoryMethodParams)[(loggerFactoryMethodParams)]

What it means

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.

Solutions

  1. Rewrite the declaration as [LoggerType ]LoggerFactoryType.loggerFactoryMethod(params), e.g. 'example.TestLogger example.TestLoggerFactory.createLogger(TOPIC)'.
  2. Include the parentheses and a valid parameter list (TOPIC or TYPE parameters, comma-separated).
  3. Verify the factory type and method names are fully qualified where required.

Example fix

// before (lombok.config)
lombok.log.customDeclaration = com.acme.LogFactory.create
// after
lombok.log.customDeclaration = com.acme.LogFactory.create(TOPIC)
Defensive patterns

Strategy: validation

Validate before calling

boolean isValidLogDeclaration(String d) {
  return d != null && d.matches("([\\w$.]+\\s+)?[\\w$.]+\\.[\\w$]+\\s*\\(([^()]*)\\)(?:\\s*\\(([^()]*)\\))?");
}

Try / catch

try {
  LogDeclaration decl = LogDeclaration.valueOf(cfgValue);
} catch (IllegalArgumentException e) {
  // surface a config-parsing error with the required pattern from the message
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of projectlombok/lombok@6d6a3e9fec (2026-09-07). Data as JSON: /api/errors/daf1e0c3cb78e333. Report an issue: GitHub.

Appendix: source

Thrown at src/core/lombok/core/configuration/LogDeclaration.java:55

	private final TypeName loggerType;
	private final TypeName loggerFactoryType;
	private final IdentifierName loggerFactoryMethod;
	private final List<LogFactoryParameter> parametersWithoutTopic;
	private final List<LogFactoryParameter> parametersWithTopic;
	
	private LogDeclaration(TypeName loggerType, TypeName loggerFactoryType, IdentifierName loggerFactoryMethod, List<LogFactoryParameter> parametersWithoutTopic, List<LogFactoryParameter> parametersWithTopic) {
		this.loggerType = loggerType;
		this.loggerFactoryType = loggerFactoryType;
		this.loggerFactoryMethod = loggerFactoryMethod;
		this.parametersWithoutTopic = parametersWithoutTopic;
		this.parametersWithTopic = parametersWithTopic;
	}
	
	public static LogDeclaration valueOf(String declaration) {
		if (declaration == null) return null;
		
		Matcher matcher = DECLARATION_PATTERN.matcher(declaration);
		if (!matcher.matches()) throw new IllegalArgumentException("The declaration must follow the pattern: [LoggerType ]LoggerFactoryType.loggerFactoryMethod(loggerFactoryMethodParams)[(loggerFactoryMethodParams)]");
		
		TypeName loggerFactoryType = TypeName.valueOf(matcher.group(2));
		TypeName loggerType = TypeName.valueOf(matcher.group(1));
		if (loggerType == null) loggerType = loggerFactoryType;
		IdentifierName loggerFactoryMethod = IdentifierName.valueOf(matcher.group(3));
		List<List<LogFactoryParameter>> allParameters = parseParameters(matcher.group(4));
		
		List<LogFactoryParameter> parametersWithoutTopic = null;
		List<LogFactoryParameter> parametersWithTopic = null;
		for (List<LogFactoryParameter> parameters: allParameters) {
			if (parameters.contains(LogFactoryParameter.TOPIC)) {
				if (parametersWithTopic != null) throw new IllegalArgumentException("There is more than one parameter definition that includes TOPIC: " + parametersWithTopic + " and " + parameters);
				parametersWithTopic = parameters;
			} else {
				if (parametersWithoutTopic != null) throw new IllegalArgumentException("There is more than one parmaeter definition that does not include TOPIC: " + parametersWithoutTopic + " and " + parameters);
				parametersWithoutTopic = parameters;
			}
		}

View on GitHub (pinned to 6d6a3e9fec)