saurav
saurav

Reputation: 5926

Enabling logs in Spring boot cloud foundry application

how do i enable spring framework logs in my application. ? i have used logback.xml in my application and set the root level to debug. When i am trying to run the app locally then logs are printed but the same is not happening when i am deploying the application in CF. The application itself is crashing due to other reason but i hoped some initial spring boot framework logging should have happened.

Below is my logback.xml file. I am not sure the console appender mentioned there will work in CF system too or not.`

 <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <layout class="ch.qos.logback.classic.PatternLayout">
            <Pattern>
                %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n
            </Pattern>
        </layout>
    </appender> 

<root level="TRACE">
<appender-ref ref="STDOUT" />
    </root>
</configuration>

Best Regards,

Saurav

Upvotes: 0

Views: 5516

Answers (2)

saurav
saurav

Reputation: 5926

May be this was a problem with the spring boot CF service broker application which was causing the logs to not be printed. Check here CF Spring boot app failed to start accepting connections

But then i deleted the application and redeployed again. It started printing logs. The above configuration works.

Upvotes: 0

ck1
ck1

Reputation: 5443

The above Logback configuration file should work. Note: TRACE level logging will produce a lot of log messages. It might be better to turn this down to INFO. You'll need to bundle this configuration file in src\main\resources\logback.xml in your Spring Boot app structure.

Application logs in PCF must be written to stdout or stderr by your app, and you can view them in the CLI using the command cf logs. The ConsoleAppender you're using above writes to stdout, so you should be good to go.

Upvotes: -1

Related Questions