There are other strong dependencies on log4j2 core. Namely LogWriterAppender and AlertAppender. Removing this dependency will require some work to define an SPI and add a layer of indirection that allows the Geode code that uses log4j2 core to be optional for a Cache.
On Tue, Apr 25, 2017 at 1:59 AM, Thacker, Dharam < [email protected]> wrote: > Hello Team, > > > > Is there any alternative way for you guys to obtain below LoggerContext > without explicitly type casting / strongly depending on > org.apache.logging.log4j.core.*Logger**? * > > > > *Class: org.apache.geode.internal.logging.LogService* > > > > *private* *static* *void* init() { > > LoggerContext context = ((org.apache.logging.log4j.core.Logger) > LogManager.*getLogger*(*BASE_LOGGER_NAME*, GemFireParameterizedMessageFac > tory.*INSTANCE*)).getContext(); > > context.removePropertyChangeListener(*propertyChangeListener*); > > context.addPropertyChangeListener(*propertyChangeListener*); > > context.reconfigure(); // propertyChangeListener invokes > configureFastLoggerDelegating > > *configureLoggers*(*false*, *false*); > > } > > > > Due to that strong and direct dependency on log4j-core/Logger instead of > SLF4JContext, it does not permit to use logback for us with below > dependency. With that direct type usage, it results into below exception > > > > Caused by: java.lang.ClassCastException: org.apache.logging.slf4j.SLF4JLogger > cannot be cast to org.apache.logging.log4j.core.Logger > > at org.apache.geode.internal.logging.LogService.init( > LogService.java:72) > > at org.apache.geode.internal.logging.LogService.<clinit>( > LogService.java:69) > > > > > > ... 35 common frames omitted > > > > <dependency> > > <groupId>org.apache.logging.log4j</groupId> > > <artifactId>log4j-to-slf4j</artifactId> > > <version>2.7</version> > > </dependency> > > > > I also tried “Using Different Front-End Logging APIs to Log to Log4j2” as > suggested from below source but that too does not work. Usually it should > work with log4j-to-slf4j which is binding for log4j2 to slf4j provided you > don’t have direct usage of org.apache.logging.log4j.core.*Logger**!* > > https://geode.apache.org/docs/guide/11/managing/logging/ > configuring_log4j2.html > > > > Thanks & Regards, > > Dharam > > This message is confidential and subject to terms at: http:// > www.jpmorgan.com/emaildisclaimer including on confidentiality, legal > privilege, viruses and monitoring of electronic messages. If you are not > the intended recipient, please delete this message and notify the sender > immediately. Any unauthorized use is strictly prohibited. >
