Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ public String lookup(LogEvent event, String key) {

@Override
public String lookup(String key) {
Assert.state(this.environment != null, "Unable to obtain Spring Environment from LoggerContext");
Assert.state(this.environment != null,
"Unable to obtain Spring Environment from LoggerContext. "
+ "This can happen if your log4j2 configuration filename does not end with '-spring' "
+ "(for example using 'log4j2.xml' instead of 'log4j2-spring.xml')");
return this.environment.getProperty(key);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ void lookupWhenNoSpringEnvironmentThrowsException() {
this.loggerContext.removeObject(Log4J2LoggingSystem.ENVIRONMENT_KEY);
Interpolator lookup = createLookup(this.loggerContext);
assertThatIllegalStateException().isThrownBy(() -> lookup.lookup("spring:test"))
.withMessage("Unable to obtain Spring Environment from LoggerContext");
.withMessage("Unable to obtain Spring Environment from LoggerContext. "
+ "This can happen if your log4j2 configuration filename does not end with '-spring' "
+ "(for example using 'log4j2.xml' instead of 'log4j2-spring.xml')");
}

private Interpolator createLookup(LoggerContext context) {
Expand Down