log.slf4j

Programmatic logging control for test support

Provides:

It’s advisable to configure this logging before anything else (Note; it will override anything already set for these “known” properties).

Existing log levels (including the default) set as system properties will not be overridden. So you may, for example, choose to use Maven profiles, setting properties to override specific levels.

For details of slf4j-simple’s system properties, see: SimpleLogger JavaDoc

Brief Examples

1. Programmatically Initialize

	logging()
			.configureFrameworks()
			.defaultLevel(INFO)
			.log("com.acme").at(DEBUG)
			.log(getClass()).at(TRACE)
			.log("com.annoying").at(ERROR);

2. Capture

	Logger acmeLogger = LoggerFactory.getLogger("com.acme");

	String wee = "Weeeeeeeeeee!";
	String captured = Logging.capture(() -> acmeLogger.info(wee));
	assertThat(captured, containsString(wee));

Static Imports

import static io.earcam.utilitarian.log.slf4j.Level.DEBUG;
import static io.earcam.utilitarian.log.slf4j.Level.ERROR;
import static io.earcam.utilitarian.log.slf4j.Level.INFO;
import static io.earcam.utilitarian.log.slf4j.Level.TRACE;
import static io.earcam.utilitarian.log.slf4j.Logging.logging;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;


Back to top

Version: 1.2.1. Last Published: 2018-11-25.

Earcam Maven Skin.