I am trying to convert a class which was earlier written using AppenderSkeleton in log4j 1.x now I am trying to migrate my service to log4j 2.6.

The code:

```
package com.amazon.digital.music.purchasing.scheduler.test;

import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;

/**
 * A log appender which collects the log messages.
 * Automatically appends itself to the root logger.
 * 
 */
 class LogMessagesCollector extends AppenderSkeleton {
 private final List<String> messages = new ArrayList<String>();

 public LogMessagesCollector() {
     final Logger logger = Logger.getRootLogger();
     logger.addAppender(this);
 }

 @Override
 public boolean requiresLayout() {
     return false;
 }

 @Override
 protected void append(final LoggingEvent loggingEvent) {
     messages.add(loggingEvent.getMessage().toString());
 }

 @Override
 public void close() {
     final Logger logger = Logger.getRootLogger();
     logger.removeAppender(this);
 }

 public List<String> getMessages() {
     return messages;
 }

```

I followed the link:
[How to Create a Custom Appender in log4j2?](https://stackoverflow.com/questions/24205093/how-to-create-a-custom-appender-in-log4j2) to understand how custom appenders are written in log4j2 but not being able to code a class which would replace this one.

Any help would be great.Thanks in advance!