56. Process Monitoring

In the spring-boot module, you can find two classes to create files that are often useful for process monitoring:

By default, these writers are not activated, but you can enable:

56.1 Extending Configuration

In the META-INF/spring.factories file, you can activate the listener(s) that writes a PID file, as shown in the following example:

org.springframework.context.ApplicationListener=\
org.springframework.boot.system.ApplicationPidFileWriter,\
org.springframework.boot.system.EmbeddedServerPortFileWriter

56.2 Programmatically

You can also activate a listener by invoking the SpringApplication.addListeners(…​) method and passing the appropriate Writer object. This method also lets you customize the file name and path in the Writer constructor.