Logback logstash json logs in different profiles in multiple projects

Viewed 169

I have a logback.xml settings file which basically says to not to use json logs when spring profile is dev, and to use json logs otherwise.

<configuration scan="all">
    <springProfile name="dev">
        ...
    </springProfile>
    <springProfile name="!dev">
        <appender name="consoleAppender" class="ch.qos.logback.core.ConsoleAppender">
            <encoder class="net.logstash.logback.encoder.LogstashEncoder">
               ...
            </encoder>
        </appender>
        <logger name="..." ...>
            ...
        </logger>
        ...
    </springProfile>
</configuration>

Now I want to do the same in multiple projects, and was thinking how do I avoid placing this file in the resources of every project, I know that there is an option to make separate project and to use it as dependency in other projects. The problem is that I didn't find any examples in the internet of how to do it correctly, I know that it's possible but I need an example (maybe a link to the guide or something like that) of how to configure it all correctly so it will work in all of the projects that will add the new project in the dependencies. Thanks in advance.

0 Answers
Related