Expecting Log4j LoggerContext in plugin library
Posted: Fri Sep 29, 2023 8:57 am
Hi,
I am working on a workbench plugin for Oxygen XML Editor 25. Our plugin uses APIs from one of our library to connect to another application from Oxygen. The library uses log4j. But we run oxygen editor from eclipse. we got following
Caused by: java.lang.ClassCastException: class org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to class org.apache.logging.log4j.core.LoggerContext (org.apache.logging.slf4j.SLF4JLoggerContext and org.apache.logging.log4j.core.LoggerContext are in unnamed module of loader 'app')
SLF4JLoggerContext
the reason is that LogManager.getContext(false) returns SLF4JLoggerContext, but the code in the library try to cast to org.apache.logging.log4j.core.LoggerContext.
Is there a way to return org.apache.logging.log4j.core.LoggerContext while LogManager.getContext(false) is called in plugin libraries?
In Oxygen XML Editor 25 there are slf4j jars.in lib. Should we remove slf4j jars from lib? is there another way to avoid the logger context issue
Thanks,
Kehua
I am working on a workbench plugin for Oxygen XML Editor 25. Our plugin uses APIs from one of our library to connect to another application from Oxygen. The library uses log4j. But we run oxygen editor from eclipse. we got following
Caused by: java.lang.ClassCastException: class org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast to class org.apache.logging.log4j.core.LoggerContext (org.apache.logging.slf4j.SLF4JLoggerContext and org.apache.logging.log4j.core.LoggerContext are in unnamed module of loader 'app')
SLF4JLoggerContext
the reason is that LogManager.getContext(false) returns SLF4JLoggerContext, but the code in the library try to cast to org.apache.logging.log4j.core.LoggerContext.
Is there a way to return org.apache.logging.log4j.core.LoggerContext while LogManager.getContext(false) is called in plugin libraries?
In Oxygen XML Editor 25 there are slf4j jars.in lib. Should we remove slf4j jars from lib? is there another way to avoid the logger context issue
Thanks,
Kehua