You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@geode.apache.org by "Kirk Lund (JIRA)" <ji...@apache.org> on 2018/12/06 19:33:00 UTC

[jira] [Resolved] (GEODE-6122) Log4j core should be optional

     [ https://issues.apache.org/jira/browse/GEODE-6122?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kirk Lund resolved GEODE-6122.
------------------------------
    Resolution: Fixed

The work to make it optional is complete although the dependencies do not have log4j core as optional. I think a good follow-up to this is to move our log4j core logging to a geode-log4j or geode-logging module.

For now, a User should be able to exclude log4j core explicitly in maven:
{noformat}
        <dependency>
            <groupId>org.apache.geode</groupId>
            <artifactId>geode-core</artifactId>
            <version>1.9.0-SNAPSHOT</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
{noformat}

And then be able to specify logback and log4j-to-slf4j as dependencies:
{noformat}
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.2.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-to-slf4j</artifactId>
            <version>2.11.1</version>
        </dependency>
{noformat}

This then results in Geode logging going to Logback. There is a new (internal for now) SPI that a Developer could use to implement Logback appenders similar to the Geode log4j appenders. I plan to follow-up to this ticket with another request that exposes the logging SPI in a non-internal package.

> Log4j core should be optional
> -----------------------------
>
>                 Key: GEODE-6122
>                 URL: https://issues.apache.org/jira/browse/GEODE-6122
>             Project: Geode
>          Issue Type: Bug
>          Components: logging
>            Reporter: Kirk Lund
>            Assignee: Kirk Lund
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> A simple test of Geode without log4j core on the classpath results in the following log statement and stack trace:
> {noformat}
> ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
> {noformat}
> {noformat}
> java.lang.NoClassDefFoundError: org/apache/logging/log4j/core/Logger
> 	at org.apache.geode.internal.logging.log4j.Log4jAgent.getRootLoggerContext(Log4jAgent.java:89)
> 	at org.apache.geode.internal.logging.log4j.Log4jAgent.getConfiguration(Log4jAgent.java:93)
> 	at org.apache.geode.internal.logging.log4j.Log4jAgent.isUsingGemFireDefaultConfig(Log4jAgent.java:78)
> 	at org.apache.geode.internal.logging.log4j.Log4jAgent.shouldUpdateLogLevels(Log4jAgent.java:127)
> 	at org.apache.geode.internal.logging.log4j.Log4jAgent.configure(Log4jAgent.java:105)
> 	at org.apache.geode.internal.logging.Configuration.configChanged(Configuration.java:175)
> 	at org.apache.geode.internal.logging.Configuration.initialize(Configuration.java:164)
> 	at org.apache.geode.internal.logging.LoggingSession.createSession(LoggingSession.java:66)
> 	at org.apache.geode.distributed.internal.InternalDistributedSystem.initialize(InternalDistributedSystem.java:663)
> 	at org.apache.geode.distributed.internal.InternalDistributedSystem.newInstance(InternalDistributedSystem.java:369)
> 	at org.apache.geode.distributed.internal.InternalDistributedSystem.newInstance(InternalDistributedSystem.java:357)
> 	at org.apache.geode.distributed.internal.InternalDistributedSystem.newInstance(InternalDistributedSystem.java:349)
> 	at org.apache.geode.distributed.DistributedSystem.connect(DistributedSystem.java:215)
> 	at org.apache.geode.cache.CacheFactory.create(CacheFactory.java:218)
> 	at io.github.kirklund.geode.GeodeApplicationIntegrationTest.setUp(GeodeApplicationIntegrationTest.java:34)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:498)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
> 	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> 	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> 	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> 	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
> 	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
> 	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
> 	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
> Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.core.Logger
> 	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
> 	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
> 	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
> 	... 38 more
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)