public class MockLogAppender
extends org.apache.log4j.AppenderSkeleton
MockLogAppender class. If you do not specify the log level specifically, the level
will default to DEBUG and you can control the level by setting the mock.logLevel
system property.
Constructor and Description |
---|
MockLogAppender()
Constructor for MockLogAppender.
|
Modifier and Type | Method and Description |
---|---|
protected void |
append(org.apache.log4j.spi.LoggingEvent event) |
static void |
assertLogAtLevel(org.apache.log4j.Level level)
assertLogAtLevel
|
static void |
assertNotGreaterOrEqual(org.apache.log4j.Level level)
assertNotGreaterOrEqual
|
static void |
assertNoWarningsOrGreater()
assertNoWarningsOrGreater
|
void |
close()
close
|
void |
doAppend(org.apache.log4j.spi.LoggingEvent event) |
static org.apache.log4j.spi.LoggingEvent[] |
getEvents()
getEvents
|
static org.apache.log4j.spi.LoggingEvent[] |
getEventsAtLevel(org.apache.log4j.Level level)
getEventsAtLevel
|
static org.apache.log4j.spi.LoggingEvent[] |
getEventsGreaterOrEqual(org.apache.log4j.Level level)
getEventsGreaterOrEqual
|
static boolean |
isLoggingSetup()
isLoggingSetup
|
static boolean |
noWarningsOrHigherLogged()
noWarningsOrHigherLogged
|
static void |
receivedLogLevel(org.apache.log4j.Level level)
receivedLogLevel
|
boolean |
requiresLayout()
requiresLayout
|
static void |
resetEvents()
resetEvents
|
static void |
resetLogLevel()
resetLogLevel
|
static void |
setupLogging()
setupLogging
|
static void |
setupLogging(boolean toConsole)
setupLogging
|
static void |
setupLogging(boolean toConsole,
Properties props)
setupLogging
|
static void |
setupLogging(boolean toConsole,
String level)
setupLogging
|
static void |
setupLogging(boolean toConsole,
String level,
Properties config)
setupLogging
|
static void |
setupLogging(Properties config)
setupLogging
|
public void doAppend(org.apache.log4j.spi.LoggingEvent event)
doAppend
in interface org.apache.log4j.Appender
doAppend
in class org.apache.log4j.AppenderSkeleton
protected void append(org.apache.log4j.spi.LoggingEvent event)
append
in class org.apache.log4j.AppenderSkeleton
public void close()
close
public boolean requiresLayout()
requiresLayout
public static void resetEvents()
resetEvents
public static org.apache.log4j.spi.LoggingEvent[] getEvents()
getEvents
LoggingEvent
objects.public static org.apache.log4j.spi.LoggingEvent[] getEventsGreaterOrEqual(org.apache.log4j.Level level)
getEventsGreaterOrEqual
level
- a Level
object.LoggingEvent
objects.public static org.apache.log4j.spi.LoggingEvent[] getEventsAtLevel(org.apache.log4j.Level level)
getEventsAtLevel
Returns events that were logged at the specified levellevel
- a Level
object.LoggingEvent
objects.public static void setupLogging()
setupLogging
public static void setupLogging(Properties config)
setupLogging
config
- a Properties
object.public static void setupLogging(boolean toConsole)
setupLogging
toConsole
- a boolean.public static void setupLogging(boolean toConsole, Properties props)
setupLogging
toConsole
- a boolean.props
- a Properties
object.public static void setupLogging(boolean toConsole, String level)
setupLogging
toConsole
- a boolean.level
- a String
object.public static void setupLogging(boolean toConsole, String level, Properties config)
setupLogging
toConsole
- a boolean.level
- a String
object.config
- a Properties
object.public static boolean isLoggingSetup()
isLoggingSetup
public static void receivedLogLevel(org.apache.log4j.Level level)
receivedLogLevel
level
- a Level
object.public static void resetLogLevel()
resetLogLevel
public static boolean noWarningsOrHigherLogged()
noWarningsOrHigherLogged
public static void assertNotGreaterOrEqual(org.apache.log4j.Level level) throws junit.framework.AssertionFailedError
assertNotGreaterOrEqual
level
- a Level
object.junit.framework.AssertionFailedError
- if any.public static void assertNoWarningsOrGreater() throws junit.framework.AssertionFailedError
assertNoWarningsOrGreater
junit.framework.AssertionFailedError
- if any.public static void assertLogAtLevel(org.apache.log4j.Level level) throws junit.framework.AssertionFailedError
assertLogAtLevel
Asserts that a message was logged at the requested level. Useful for testing code that *should* have logged an error message (or a notice or some other special case)level
- a Level
object.junit.framework.AssertionFailedError
- if any.Copyright © 2015. All Rights Reserved.