Skip to content

This is a utility I wrote that tests log4j statement logging behaviors

Notifications You must be signed in to change notification settings

trescube/Log4jMonitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Log4jMonitor

utility to make testing log4j message writing easier

Basic Usage Guide

See unit tests, but here's a quick example:

public class MyClass() {
    private Logger logger = Logger.getLogger(MyClass.class);

    public MyClass() {
        logger.info("MyClass instantiated");
    }

}

public class MyClassTest {
    @Test
    public void myClassInstantiationShouldLogINFOStatement() {
        Log4jMonitor log4jMonitor = new Log4jMonitor();
    
        MyClass myClass = new MyClass();
    
        assertThat(log4jMonitor.getStatementCount(Level.INFO), is(1));
        assertThat(log4jMonitor.hasStatements(Level.ERROR), is(false));
        assertThat(log4jMonitor.isInfoStatement("MyClass instantiated"), is(true));
    
    }

}

About

This is a utility I wrote that tests log4j statement logging behaviors

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published