Skip to content
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

Exclude logback configuration #103

Open
nmiljkovic opened this issue Apr 9, 2020 · 5 comments
Open

Exclude logback configuration #103

nmiljkovic opened this issue Apr 9, 2020 · 5 comments
Assignees

Comments

@nmiljkovic
Copy link

Hello CurrencyCloud team :),

You should consider removing logback.xml from the package and instead letting users configure their own logging.

  1. Library users might not use logback,
  2. Library users might want to have their own logback config (eg. structured JSON logging).

I encountered an issue when setting up a Spring Boot app which didn't appear to log anything, traced it to currencycloud-java. :)

@gyorgy-marbella
Copy link
Contributor

I have the same problem. @nmiljkovic how did you solve this problem?

@nmiljkovic
Copy link
Author

nmiljkovic commented Dec 21, 2020

@gyorgy-marbella When loading configuration, any classpath resources which are in your project will have priority. I have simply added src/main/resources/logback.xml with my own logback configuration:

<configuration>
    <include resource="org/springframework/boot/logging/logback/base.xml"/>

    <!-- configure anything special here -->
</configuration>

@gyorgy-marbella
Copy link
Contributor

gyorgy-marbella commented Dec 21, 2020

thanks for the quick reply @nmiljkovic . We are using the spring logback extension (logback-spring.xml) and it is ignored if I add logback.xml

logback-spring.xml

<configuration>
    <springProfile name="!aws">
        <include resource="org/springframework/boot/logging/logback/base.xml"/>
    </springProfile>

    <springProfile name="aws">
        <appender name="jsonConsoleAppender" class="ch.qos.logback.core.ConsoleAppender">
            <encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
        </appender>
        <root level="INFO">
            <appender-ref ref="jsonConsoleAppender"/>
        </root>
    </springProfile>
</configuration>

@nmiljkovic
Copy link
Author

@gyorgy-marbella yes, unfortunately logback-spring.xml does not load because the priority is always taken by logback.xml from currencycloud-java. :(

I have not been able to find a workaround regarding this and make logback-spring.xml work.

@gyorgy-marbella
Copy link
Contributor

I found a workaround, added the following to the application.yaml

logging:
  config: classpath:logback-spring.xml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants