Skip to content

schnatterer/logback-spike

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code
This branch is 19 commits ahead of thekua:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 

logback-spike

Build Status JitPack License

Logback and SLF4j unit testing.

Original idea from thekua's blog, forked from his repo in order to provide it conveniently with good reuse as maven dependency.

Usage

Get it via JitPack, for example using maven.

Add the following maven repository to your POM.xml

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Then add the actual dependency

<dependency>
    <groupId>com.github.schnatterer</groupId>
    <artifactId>logback-spike</artifactId>
    <version>1.0.0</version>
    <scope>test</scope>
</dependency>

From here it's really simple to use:

// Given
LogbackCapturingAppender capturing = LogbackCapturingAppender.weaveInto(OurDomainWithLogger.LOG);

// when
new OurDomainWithLogger().logInfo("This should be logged{}", "!");

// then
assertThat(capturing.getCapturedLogMessages().get(0), is("This should be logged!"));

See LogbackCapturingAppender's javadoc and its unit test for more insights.

Packages

No packages published

Languages

  • Java 100.0%