IMAP Disruptor ile tüm Log4J 2 günlükleyicilerini eşzamansız yapmaya çalışıyorum. Bozucu bağımlılıkları doğru şekilde ayarlıyorum ve IntelliJ'te, VM seçenekleri altında aşağıdaki sistem özelliğini ayarladım.Log4J 2 Async Logger ve Konuları
-DLog4jContextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
Benim log4j2.xml dosyam budur.
Kaydedici sınıfım bu koda sahiptir.
package guru.springframework.blog.log4j2async;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Log4J2AsyncLogger {
private static Logger logger = LogManager.getLogger();
public Log4J2AsyncLogger(){
logger.info("Logger created by Thread Id:"+Thread.currentThread().getId());
}
public void performSomeTask(){
logger.debug("This is a debug message sent by Thread Id:" + Thread.currentThread().getId());
logger.info("This is a info message sent by Thread Id:" + Thread.currentThread().getId());
logger.warn("This is a warn message sent by Thread Id:" + Thread.currentThread().getId());
logger.error("This is a error message sent by Thread Id:" + Thread.currentThread().getId());
logger.fatal("This is a fatal message sent by Thread Id:" + Thread.currentThread().getId());
}
}
Farklı iş parçacığı kimlikleriyle günlük iletilerinin çıktısını bekledim. Ama, konsol ve dosya çıkışları hem şunlardır: logger sınıfta
[INFO ] 2016-03-25 11:41:01.189 [main] Log4J2AsyncLogger - System property Log4jContextSelector: org.apache.logging.log4j.core.async.AsyncLoggerContextSelector
[INFO ] 2016-03-25 11:41:01.189 [main] Log4J2AsyncLogger - Logger created by Thread Id:1
[DEBUG] 2016-03-25 11:41:01.189 [main] Log4J2AsyncLogger - This is a debug message sent by Thread Id:1
[INFO ] 2016-03-25 11:41:01.189 [main] Log4J2AsyncLogger - This is a info message sent by Thread Id:1
[WARN ] 2016-03-25 11:41:01.189 [main] Log4J2AsyncLogger - This is a warn message sent by Thread Id:1
[ERROR] 2016-03-25 11:41:01.189 [main] Log4J2AsyncLogger - This is a error message sent by Thread Id:1
[FATAL] 2016-03-25 11:41:01.189 [main] Log4J2AsyncLogger - This is a fatal message sent by Thread Id:1
, ben günlük mesajları 1000 döngüler ile döngü için kullanarak çalıştı, ancak hala aynı ana iş parçacığı tüm çalışmaları yapıyor. Neyi yanlış yapıyorum?