I have deployed springboot application in PCF . I want to log the message based on the environment variable .What should I do so that the run time log level change will work without restarting the application?

It's worth emphasizing that the Actuator loggers endpoint was added in 1.5.1 and if you have an older Spring Boot app using < 1.5.1 with Actuator, even though there are other Actuator endpoints provided, you won't find the one for loggers. I know because I just spent ages trying to work out why it wouldn't turn on :-)
– Kevin HookeFeb 10 at 1:57

For Spring Boot 2.1 you have to make sure that the loggers endpoint is exposed to web by adding loggers value to management.endpoints.web.exposure.include setting. If you don't have such line in your application.properties file, than add: management.endpoints.web.exposure.include=health,info,loggers, since its default is health,info
– DennisNov 27 at 16:25

If you are using logback api to configure logging in the project then you can use the AutoScan feature of logback api.
As per documentation

logback-classic will scan for changes in its configuration file and
automatically reconfigure itself when the configuration file changes.
In order to instruct logback-classic to scan for changes in its
configuration file and to automatically re-configure itself set the
scan attribute of the element to true.

The default logging provider is logback. To setup your system so that the logging level can be changed at runtime you need to perform the following steps:

Firstly in src/main/resources create a custom logback configuration named logback-spring.xml that includes spring's default configurator and then adds the directive that exposes logback configuration over JMX:

Now add a dependency on the Jolokia JMX-over-HTTP bridge: org.jolokia:jolokia-core.

You should now be able to hit /jolokia endpoints on your spring boot application. The protocol is documented here. It's not pretty. To get you started, here's a few GET examples that you can hit straight from a browser:

If you use Log4j 2 for logging you can easily configuration it to set the log level to use based on an environment variable or system property. If you do it this way you won't need to modify the file just because the environment changed.