What Is The Best Way To Use One Logging Config In A Multi-Project Gradle Build

Answered

I have a multi-module gradle project and I want to use a single logging config file in all of the modules without copying and pasting.

If I use sourceSets in each gradle module to point to the same file in the root then IDEA complains that the same config appears in multiple modules.

If I use processResources in each module it outputs to the jar file but IDEA does not pick it up when debugging locally.

What is the recommended approach for using a single logging config that works in IDEA as well as in the final gradle build?

0
3 comments

What logging framework do you use? Normally there should be a way to override the configuration via VM options/environment variables, files in some fixed locations despite using the classpath.

You can edit the default run/debug configuration in IntelliJ IDEA with the option to set up logging and all the code you will run will use the same logging for this project.

0

I tend to use Logback or Log4J2.

This option looks interesting

www.jetbrains.com/help/idea/2018.1/runner.html

Delegate IDE build/run actions to Gradle Select this checkbox to delegate the following actions to Gradle:
  • assemble and compile project files

Is there a way to share this config in the project so that the next person who checks it out gets the expected behaviour?

 

0

https://stackoverflow.com/questions/19518843/logback-configuration-via-jvm-argument may be a better way.

You can share IntelliJ IDEA run/debug configurations in .idea directory.

0

Please sign in to leave a comment.