Question: I am trying to make a macro that will make a chart for me out of two columns of data. I keep coming across this error no matter what I do. I've attached an image here. 

[![enter image description here](https://i.stack.imgur.com/1PrCG.png)](https://i.stack.imgur.com/1PrCG.png)

Answer: 
`log4j2.xml`

```
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <Appenders>
        <Routing name="RoutingAppender">
            <Routes pattern="${ctx:logFileName}">
                <Route>
                    <RollingFile name="Rolling-${ctx:logFileName}"
                                 fileName="./logs/${ctx:logFileName}.log"
                                 filePattern="./logs/${ctx:logFileName}.%i.log.gz">
                        <PatternLayout pattern="%d{HH:mm:ss.SSS} [%-5level] %logger{36} - %msg%n"/>
                        <SizeBasedTriggeringPolicy size="512" />
                    </RollingFile>
                </Route>
            </Routes>
        </Routing>
    </Appenders>

    <Loggers>
        <Root level="all">
            <AppenderRef ref="RoutingAppender" />
        </Root>
    </Loggers>
</Configuration>

```

Source code

```
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.ThreadContext;

public class Log4j2Test{
    static Logger logger = LogManager.getLogger(Log4j2Test.class);

    public static void main(String[] args) {
        ThreadContext.put("logFileName", "testFile1" );
        logger.info("log printed! - testFile1");

        ThreadContext.put("logFileName", "testFile2" );
        logger.info("log printed! - testFile2");

        ThreadContext.remove("logFileName");
    }

}

```

output : testFile1.log

```
16:27:51.868 [INFO ] com.test.Log4j2Test- log printed! - testFile1

```

output : testFile2.log

```
16:27:51.897 [INFO ] com.test.Log4j2Test- log printed! - testFile2

```
Finally found the solution. I hope it will be useful . 

```
  <Routing name="RoutingAppender">
        <Routes pattern="$${ctx:RequestId}">
            <Route>
                <RollingFile name="Rolling-${ctx:RequestId}" fileName="C:\XXX\a58086\XXXX\logs\${ctx:RequestId}.log"
                             filePattern="C:\XXXX\XXXX\Desktop\logs\$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
                    <PatternLayout pattern="%d{ABSOLUTE} %level{length=5} [%thread] %logger{1} - %msg%n"/>
                    <SizeBasedTriggeringPolicy size="512" />
                </RollingFile>
            </Route>

            <Route ref="Console" key="${ctx:RequestId}"/>
        </Routes>
    </Routing>

```