New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Dropwizard applications without logback #1900

Merged
merged 3 commits into from Mar 28, 2017

Conversation

Projects
None yet
6 participants
@arteam
Member

arteam commented Jan 24, 2017

This is a prototype for splitting the tight integration between Dropwizard and Logback. This feature was requested several times (See #1367). The idea is too provide users the ability to exclude Logback from Dropwizard and replace it with an external logging solution, if they really want to. The main work of this PR is too initialize the Logback infrastructure lazily, so the user can swap it to an external logging mechanism in the config file.

With this change users can swap logback to other logging implementation like that:

 <dependencies>

        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-core</artifactId>
            <version>1.1.0-SNAPSHOT</version>
            <exclusions>
                <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-classic</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>ch.qos.logback</groupId>
                    <artifactId>logback-access</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.21</version>
        </dependency>

    </dependencies>
server:
  type: simple
  applicationContextPath: /application
  adminContextPath: /admin
  connector:
    type: http
    port: 8080
  requestLog:
    type: external
logging:
  type: external
public class ExampleApplication extends Application<ExampleConfiguration> {

    @Override
    protected void bootstrapLogging() {
    }
}

@arteam arteam force-pushed the remove_logback_dependency branch from 0b1d9e3 to c4e5c3d Feb 16, 2017

@arteam arteam changed the title from [WIP] Support Dropwizard applications without logback to Support Dropwizard applications without logback Mar 13, 2017

@arteam arteam force-pushed the remove_logback_dependency branch from c4e5c3d to 7f5bccf Mar 13, 2017

@coveralls

This comment has been minimized.

coveralls commented Mar 13, 2017

Coverage Status

Coverage decreased (-0.05%) to 84.272% when pulling 7f5bccf on remove_logback_dependency into 243874e on master.

@arteam

This comment has been minimized.

Member

arteam commented Mar 13, 2017

@dropwizard/committers Could you please review? This should be ready to merge. I tested it locally and it works with custom logging solutions. Would be nice to polish it and adopt to the framework.

@jplock jplock added this to the 1.2.0 milestone Mar 13, 2017

@jplock jplock added the feature label Mar 13, 2017

@jplock

jplock approved these changes Mar 13, 2017

@jplock

This comment has been minimized.

Member

jplock commented Mar 13, 2017

@arteam mind updating the release notes too?

@arteam

This comment has been minimized.

Member

arteam commented Mar 13, 2017

Will do. It probably make sense to mention in the docs how to switch to an external logging.

@jplock

This comment has been minimized.

Member

jplock commented Mar 27, 2017

@arteam this is just pending documentation, correct?

@arteam

This comment has been minimized.

Member

arteam commented Mar 27, 2017

Correct, I need to get my hands on it. Will do today.

arteam added some commits Nov 10, 2016

Support Dropwizard applications without logback
This is a prototype for splitting the tight integration between Dropwizard and Logback.
This feature was requested several times (See #1637). The idea is too provide users the
ability to exclude Logback from Dropwizard and replace it with an external logging
solution, if they really want to. The main work of this PR is too initialize the Logback
infrastructure lazily, so the user can swap it to an external logging mechanism in the
config file.
Mention in the docs how do exclude Logback
For people who use Spark which forces log4j2.

@arteam arteam force-pushed the remove_logback_dependency branch from d4af0bb to ca583fa Mar 28, 2017

@coveralls

This comment has been minimized.

coveralls commented Mar 28, 2017

Coverage Status

Coverage decreased (-0.05%) to 84.481% when pulling df3a6df on remove_logback_dependency into efb9e0e on master.

@arteam

This comment has been minimized.

Member

arteam commented Mar 28, 2017

I've added docs about disabling Logback to the core guide.

@jplock

This comment has been minimized.

Member

jplock commented Mar 28, 2017

Thanks!

@jplock jplock merged commit 3034407 into master Mar 28, 2017

@jplock jplock deleted the remove_logback_dependency branch Mar 28, 2017

@vybs

This comment has been minimized.

vybs commented Apr 26, 2017

@arteam is there a slated release for this anytime soon, i,e 1.2.0 ?

@arteam

This comment has been minimized.

Member

arteam commented Apr 27, 2017

We don't have an ETA for 1.2.0, unfortunately. You can use snapshots builds for the time being, if you want to test this feature.

We could cut a release candidate for 1.2.0, but we need to discuss this among the maintainers.

@whitfin

This comment has been minimized.

whitfin commented May 15, 2017

@arteam is there a repository holding the latest snapshot of Dropwizard, or do we have to build it ourselves?

(also, thank you greatly for this PR, works perfectly)

@arteam

This comment has been minimized.

Member

arteam commented May 15, 2017

I think you can use the Nexus snapshot repository, our snapshots should be there:

<repository>
  <id>sonatype-nexus-snapshots</id>
  <name>Sonatype Nexus Snapshots</name>
  <url>http://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
@jsauvain

This comment has been minimized.

jsauvain commented Jul 23, 2017

@arteam

I just tried to use this feature with 1.2.0-SNAPSHOT from nexus.

io.dropwizard.jackson.LogbackModule imports the Level class from Logback. Could you please fix that?

java.lang.NoClassDefFoundError: ch/qos/logback/classic/Level
        at io.dropwizard.jackson.LogbackModule$LogbackDeserializers.findBeanDeserializer(LogbackModule.java:49)
        at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory._findCustomBeanDeserializer(BasicDeserializerFactory.java:1657)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:102)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:403)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:349)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
        at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
        at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:476)
        at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:3899)
        at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3765)
        at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2099)
        at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:128)
        at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:92)
        at io.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:124)
        at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:72)
        at io.dropwizard.cli.Cli.run(Cli.java:74)
        at io.dropwizard.Application.run(Application.java:93)
@arteam

This comment has been minimized.

Member

arteam commented Jul 23, 2017

Thanks for pointing this out. It seems the configuration of the Jackson's ObjectMapper in Dropwizard is still dependent on Logback. I will take a look on it.

@karussell karussell referenced this pull request Mar 27, 2018

Merged

Dropwizardify - really now #1314

9 of 9 tasks complete

aaanders added a commit to aaanders/dropwizard that referenced this pull request Sep 20, 2018

Support Dropwizard applications without logback (dropwizard#1900)
* Support Dropwizard applications without logback

This is a prototype for splitting the tight integration between Dropwizard and Logback.
This feature was requested several times (See dropwizard#1637). The idea is too provide users the
ability to exclude Logback from Dropwizard and replace it with an external logging
solution, if they really want to. The main work of this PR is too initialize the Logback
infrastructure lazily, so the user can swap it to an external logging mechanism in the
config file.

* Mention in the docs how do exclude Logback

For people who use Spark which forces log4j2.

* Add dropwizard#1900 to the release notes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment