|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.qpid.util.LogMonitor
public class LogMonitor
Utility to simplify the monitoring of Log4j file output Monitoring of a given log file can be done alternatively the Monitor will add a new log4j FileAppender to the root Logger to gather all the available logging for monitoring
Constructor Summary | |
---|---|
LogMonitor()
Create a new LogMonitor that creates a new Log4j Appender and monitors all log4j output via the current configuration. |
|
LogMonitor(File file)
Create a new LogMonitor on the specified file if the file does not exist or the value is null then a new Log4j appender will be added and monitoring set up on that appender. |
Method Summary | |
---|---|
void |
close()
Stop monitoring this file. |
List<String> |
findMatches(String pattern)
Checks the log for instances of the search string. |
File |
getMonitoredFile()
Return a File reference to the monitored file |
String |
readFile()
Read the log file in to memory as a String |
void |
reset()
Clears the log file and writes: 'Log Monitor Reset' at the start of the file |
List<String> |
waitAndFindMatches(String message,
long wait)
Checks the log file for a given message to appear and returns all instances of that appearance. |
boolean |
waitForMessage(String message,
long alertLogWaitPeriod)
|
boolean |
waitForMessage(String message,
long wait,
boolean printFileOnFailure)
Checks the log file for a given message to appear. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LogMonitor() throws IOException
IOException
- if there is a problem creating the temporary file.public LogMonitor(File file) throws IOException
file
- the file to monitor
IOException
- if there is a problem creating a temporary fileMethod Detail |
---|
public List<String> waitAndFindMatches(String message, long wait) throws FileNotFoundException, IOException
message
- the message to wait for in the logwait
- the time in ms to wait for the message to occur
FileNotFoundException
- if the Log file can nolonger be found
IOException
- thrown when reading the log filepublic List<String> findMatches(String pattern) throws IOException
String.contains(CharSequences)
pattern
- the search string
IOException
- if there is a problem with the filepublic boolean waitForMessage(String message, long wait, boolean printFileOnFailure) throws FileNotFoundException, IOException
message
- the message to wait for in the logwait
- the time in ms to wait for the message to occurprintFileOnFailure
- should we print the contents that have been
read if we fail ot find the message.
FileNotFoundException
- if the Log file can nolonger be found
IOException
- thrown when reading the log filepublic boolean waitForMessage(String message, long alertLogWaitPeriod) throws FileNotFoundException, IOException
FileNotFoundException
IOException
public String readFile() throws FileNotFoundException, IOException
FileNotFoundException
- if the Log file can nolonger be found
IOException
- thrown when reading the log filepublic File getMonitoredFile()
public void reset() throws FileNotFoundException, IOException
FileNotFoundException
- if the Log file can nolonger be found
IOException
- thrown if there is a problem with the log filepublic void close()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |