Pivotal Cloud Foundry - Application Logging - java

I have a microservice developed using Spring Boot. The application is deployed in pivotal cloud foundry. I have set the logs levels in logback.xml which is part of the application. In order to change the log level , I have to update the logback.xml and rebuild / redeploy the app. Is there a better way to do this without having to redeploy the app? Is there a way to set log level as env variable in PCF?

I have not used logback so don't know much on it. But may be this thread can help - Set Logging Level in Spring Boot via Environment Variable

If you are using Spring Boot 1.5 or higher, and PCF 1.9 or higher you can change log levels from the Apps Manager without having to redeploy:
http://docs.pivotal.io/pivotalcf/1-9/console/using-actuators.html#manage-log-levels

Have you ever thought of externalizing your application configuration.... Pcf provides a service called config-server, which uses a git repo for maintaining your application configuration....
Using spring boot actuator, you can actually reload the updated configuration without actually doing redeploy/rebuild of your app.
This links should help you:
https://docs.pivotal.io/spring-cloud-services/1-5/common/config-server/index.html
https://spring.io/guides/gs/centralized-configuration/

Related

Reload Properties into Java application running inside kubernetes

I am deploying plain Java application and spring application(without spring boot) into kubernetes.
I have planned to mount config map into a volume and refer it as part of deployment yaml file.
Query:
If I update the config map, I want the application to reload the properties .
I have seen some references where this can be done with spring cloud and it provides access to kubernetes as well.
I want to know if by any way the same can be done for normal Java application and a Spring application.

How to Modify application.properties file dynamically in spring application?

Currently we have spring applications which are deployed on to Tomcat Servers.We are trying to update application.properties dynamically on the fly, without restarting our server/service. What are our options?
Do we need right any polling service which listens to event changes and update props file?
You can use the Spring Config project. As per the microservice architecture, you can define a different spring profile based on the environment and you will get the capability to reload application properties on the fly without restarting the application using Spring cloud bus events. The same setup can be useful in monolithic architecture as well.

What's best practice for configuring logs of Spring Boot app running on ECS

We have a suite of microservices that are currently hosted on AWS ECS-Fargate. They are implemented using Spring Boot and packaged as a Docker container using an OpenJDK-based image.
Application logging is configured using logging.config from the Spring runtime core properties and currently points to a bundled classpath resource as follows:
logging:
config: 'classpath:config/logback-spring.xml'
At the ECS task level we configure logs using the awslogs driver which redirects all console output to AWS CloudWatch.
However, this approach is quickly proving unwieldy as it requires us to rebuild and subsequently redeploy the microservices everytime we need to modify the logging configuration.
What is the current best practice for configuring logs using resources external to the application when hosted within the AWS environment?

How to run multiple Spring Boot applications easily on Production

I am trying to figure out an easy way to manage many Spring Boot applications on my Production server. Right now I have many fat jars running on different folders where each one has its your own script to start/stop the application and there's an external folder for the configurations (logback, properties, xml). For record those configurations are loaded by command line -Dloader.path to Spring Boot execution.
So how can I avoid conflicts for the same http/https port already running on Production? Does exist any kind of application manager where system administrators could control it? One solution I found was to virtualize Spring Boot applications with Docker, but my environment is Unix Solaris.
Is there any java solution for this scenario?
You can have a look at Spring Cloud which will give you better control and management when running multiple boot applications. All components of Spring Cloud
might not be useful to you, but few of them will help in port resolution, service rerouting and property maintenance. Along with the above you can also try SBA.
Along with the above you can also try Nginx for UI load balancing and reverse proxy.

Spring Integration + Spring Boot Actuator Endpoints not showing up

I have been trying to learn more about Spring Boot and I would like to add the Actuator endpoints to my test Spring integration/Spring Boot project. However, it is a plain, CLI Spring integration project--there are no current REST or web services. I'd ideally like to add the ability to view the endpoints with a browser while the jar is running from the command line.
I have been looking through the tutorials and I'm not finding a lot on adding it to a regular project, rather than a web project.
I've added the dependencies (spring-boot-actuator), and can see the endpoints from the jconsole, but I never see a connection to a port on my system (using netstat) and never can navigate there.
Is there a tutorial or something that can show me how to have REST endpoints with a CLI project?
Thank you
newbo
You can monitor and manage your application using JMX instead. See the documentation here.
If you use IntelliJ IDEA, hit CTRL+Space in an application.properties file to see a lot of JMX properties ready for you, one of them being:
endpoints.jmx.enabled=true (true is the default value)
According to Spring Docs, in order to show the endpoint user need to have ACTUATOR role.If you need to access without having the role you need to add the following value to application.properties:
management.security.enabled=false
I think if it isn't a web project, no tomcat servlet will be embedded, therefor you wont be able to browse the actuator endpoints over http
Insert dependency spring-boot-starter-web into your project and it will probably work.

Categories