Class MockLogger

java.lang.Object
java.util.logging.Logger
org.apache.juneau.rest.mock.MockLogger

public class MockLogger extends Logger
Simplified logger for intercepting and asserting logging messages.
Example:

// Instantiate a mock logger. MockLogger logger = new MockLogger(); // Associate it with a MockRestClient. MockRestClient .create(MyRestResource.class) .json5() .logger(logger) .logRequests(DetailLevel.FULL, Level.SEVERE) .build() .post("/bean", bean) .complete(); // Assert that logging occurred. logger.assertLastLevel(Level.SEVERE); logger.assertLastMessage().is( "=== HTTP Call (outgoing) ======================================================", "=== REQUEST ===", "POST http://localhost/bean", "---request headers---", " Accept: application/json5", "---request entity---", " Content-Type: application/json5", "---request content---", "{f:1}", "=== RESPONSE ===", "HTTP/1.1 200 ", "---response headers---", " Content-Type: application/json", "---response content---", "{f:1}", "=== END =======================================================================", "" );

See Also: