6

I want to make some loggers asynchronous in log4j2.properties file. In the xml format you can add as

<Loggers>
    <AsyncLogger name="com.foo.Bar" level="info">
    </AsyncLogger>
</Loggers>

I tried it in log4j2.properties as loggers = com-foo-Bar

asyncLogger.com-foo-Bar.name = com.foo.Bar
asyncLogger.com-foo-Bar.level = INFO

But this syntax seems to be wrong.

What is the correct way to configure it?

Asma Zinneera Jabir
  • 801
  • 3
  • 13
  • 31

1 Answers1

4

Below is one way of using AsyncLogger in log4j2 properties file -

logger.com.foo.Bar.type = AsyncLogger
logger.com.foo.Bar.name = com.foo.Bar
logger.com.foo.Bar.level = info
Vikas Sachdeva
  • 5,633
  • 2
  • 17
  • 26
  • Thank you for the answer. How do I know that the AsyncLoggers are being used. I debugged with breakpoints in org.apache.logging.log4j.core.async.AsyncLogger but it didn't get hit. – Asma Zinneera Jabir Oct 09 '17 at 07:01
  • enable debug or trace logs by changing `status` in `log4j2.properties` file - `status = debug` then in logs, you can see `AsyncLogger` is getting created. – Vikas Sachdeva Oct 09 '17 at 08:33