Ensure non-remapped calls are still logged

Update LevelRemappingAppender to that any calls that aren't remapped
are still logged.

Fixes gh-1481
pull/1588/head
Phillip Webb 10 years ago
parent f46fe32264
commit bedb44adc8

@ -52,11 +52,9 @@ public class LevelRemappingAppender extends AppenderBase<ILoggingEvent> {
@Override
protected void append(ILoggingEvent event) {
Level remappedLevel = this.remapLevels.get(event.getLevel());
if (remappedLevel != null) {
AppendableLogger logger = getLogger(this.destinationLogger);
logger.callAppenders(new RemappedLoggingEvent(event));
}
Level remapped = this.remapLevels.get(event.getLevel());
logger.callAppenders(remapped == null ? event : new RemappedLoggingEvent(event));
}
protected AppendableLogger getLogger(String name) {

@ -86,6 +86,13 @@ public class LevelRemappingAppenderTests {
assertThat(this.logCaptor.getAllValues().get(1).getLevel(), equalTo(Level.WARN));
}
@Test
public void notRemapped() throws Exception {
this.appender.append(mockLogEvent(Level.TRACE));
verify(this.logger).callAppenders(this.logCaptor.capture());
assertThat(this.logCaptor.getAllValues().get(0).getLevel(), equalTo(Level.TRACE));
}
private ILoggingEvent mockLogEvent(Level level) {
ILoggingEvent event = mock(ILoggingEvent.class);
given(event.getLevel()).willReturn(level);

Loading…
Cancel
Save