int DEFAULT_NO_OF_LOGS = 100;
int definedAmount;
Appender appender = Logger.getRootLogger().getAppender(
LoggingConstants.WSO2CARBON_MEMORY_APPENDER);
if (appender instanceof MemoryAppender) {
MemoryAppender memoryAppender = (MemoryAppender) appender;
if ((memoryAppender.getCircularQueue() != null)) {
definedAmount = memoryAppender.getBufferSize();
} else {
return NO_LOGS_MESSAGE;
}
Object[] objects;
if (definedAmount < 1) {
objects = memoryAppender.getCircularQueue().getObjects(DEFAULT_NO_OF_LOGS);
} else {
objects = memoryAppender.getCircularQueue().getObjects(definedAmount);
}
if ((memoryAppender.getCircularQueue().getObjects(definedAmount) == null)
|| (memoryAppender.getCircularQueue().getObjects(definedAmount).length == 0)) {
return NO_LOGS_MESSAGE;
}
Layout layout = memoryAppender.getLayout();
List<LogMessage> resultList = new ArrayList<LogMessage>();
for (int i = 0; i < objects.length; i++) {
LoggingEvent logEvt = (LoggingEvent) objects[i];
if (logEvt != null) {
String result = layout.format(logEvt);