Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I integrate Spring Cloud with logback?

I have two Spring Boot applications:

  1. cloud-config

    It has following file structure:

    └───src
        └───main
            └───environment
                └───default
                    ├───application.yml
                    └───bootstrap.yml
    ...
    

    application.yml:

    server:
      port: 8087
    
    spring:
      cloud:
        config:
          server:
            git:
              uri: ssh://path-to-repository.git
    

    bootstrap.yml:

    spring:
      application:
        name: cloud-config  
    
  2. main-application:

    └───src
        └───main
            └───environment
                └───default
                    ├───bootstrap.yml
                    └───logback.xml
    

    I have application.yml for my main-application in git repository.

Also in git repository I have file with properties: application-default.properties.

I want to move logback.xml to git repository to get it with spring-cloud. How can I do this?

like image 522
Roman Cherepanov Avatar asked Feb 27 '17 18:02

Roman Cherepanov


1 Answers

To solve my task I have done following:

  1. add logback.xml to my Spring Cloud repository;

  2. remove logback.xml from main > environment > default directory;

  3. add to bootstrap.yml of main-application module:

    logging:
        config: http://localhost:8087/main-application/default/master/logback.xml
    

  • Documentation: description of logging: config: path: Serving plain text
like image 88
Roman Cherepanov Avatar answered Sep 23 '22 17:09

Roman Cherepanov