How does Spring Boot get the local server properties? - spring

I am using the Spring Boot to develop a application. When startup a spring boot application, I got a log message like
com.xerox.eppic.report.Application : Starting Application on {{server name}} with PID {{PID}}
I want to know, how does Spring Boot get my server information? I need this information to develop some other features.
I have added the line number to log message, the line number for my main class is not correct. I have read some source code of Spring Boot, I didn't find where Spring Boot read the server info.

The class responsible of this is StartupInfoLogger. Check the code for more details.
In short the server name is retrieved by the INetAddress class and the PID system property is set by ApplicationPid

Related

How to check the java application (non spring boot) if it is up or down

I have this requirement that I need to check if the java application (not web app) is running or down via bash script.
It is non springboot application as well. It is just a normal spring application that connects and listen to kafka, get the the object from the topic and call an API.
We thought of to use spring actuator to check the health however it is not a web application.
What is the recommended way to check a non-web and non-springboot application if it is up or down?
Please advise.

Log action in Spring Boot Admin

How to configure Spring Boot Admin to log action. For example, I want Spring Boot Admin log action when someone change log level form INFO to DEBUG or when someone change configuration value in JMX tab and write wrong configure override the existing.
Do Spring Boot Admin has a feature to do that?
No it doesn't but you could write a zuul filter intercepting, analyzing the request to /api/applications/{id}/logfile and writing a log statement.
Spring Boot includes a number of additional features to help you
monitor and manage your application when it’s pushed to production.
You can choose to manage and monitor your application using HTTP
endpoints, with JMX or even by remote shell (SSH or Telnet). Auditing,
health and metrics gathering can be automatically applied to your
application.
Actuator HTTP endpoints are only available with a Spring MVC-based
application. In particular, it will not work with Jersey unless you
enable Spring MVC as well.
You can also activate a listener by invoking the SpringApplication.addListeners(…​) method and passing the appropriate Writer object. This method also allows you to customize the file name and path via the Writer constructor.
Customize your requirement in Actuator
https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready
Maven :
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
    <version>1.5.2.RELEASE</version>
</dependency>
http://www.baeldung.com/spring-boot-authentication-audit

How to serve up logging files in a html page?

We are using spring boot for our Web Service. The logging is implemented by using logback. The application is deployed in a Red Hat Linux box and now if we want to browse over the logs we don't want to look through the plain text version. There needs to be static html page to serve it up. I tried looking at the examples but no one tried for logging.
Spring Boot Admin is a separate application which offers admin features over any Spring Boot app. These featues include a logfile-endpoint which allows you to see and tail logfile(s) produced by a Spring Boot app. By default, that endpoint will provide access to the log file defined by the Spring Boot logging.file property and you can also configure a non Spring Boot managed logfile by defining the property: endpoints.logfile.external-file.
If that tool is not a runner then your options might be:
logviewer
Roll your own, for example ...
Use Commons IO Tailer to tail your file, via a file mount on the target server or remotely using Jsch perhaps
Use a SocketAppender to emit log events from the server and consume those log events on the client side for display in the browser
Log Viewer solves this problem. It provides a web page to monitor logs on a server. Full access to the log file is available, not only tail. Filtering, highlighting is supported as well. No problem with big files.
The tool can be added to a spring boot application as a library and works inside the application, or can be run standalone.

Spring Boot to Spring XD conversion

I have an existing stand-alone Spring Boot (CommandLineRunner) application that generates JSON payloads, currently written to the local file system. Though I could tail that file easily in Spring XD, I'd rather have the entire Spring Boot application run as either a source or job module in Spring XD, but I'm having some difficulties making the conversion. Does anyone know of a Spring XD sample where the XD module (source or job) is the creator/originator of outgoing messages, instead of using some sort of inbound adapter from another external system? (Maybe my entire premise is misguided, but I want the application to be managed by Spring XD so that I don't have to manage another out-of-band orchestration tool to start and stop the JSON-generating process.)

Using Spring Console Extension in WebLogic 10.3.4.0 with Spring 3.0.3

I've a Spring 3.0.3-based EAR+WAR which I'm deploying to WebLogic 10.3.4.0. I want to be able to see my the various framework Spring Beans at runtime via JMX and ideally in the WebLogic console. (Note, these are NOT bean's we've written but the ones which come by default with Spring.)
Ideally we'd have been able to get it working with the WebLogic Spring Console Extension as described here. However after following all these steps (plus adding the weblogic-spring.jar to our WAR after we saw ClassNotFoundException errors in our WebLogic log when trying to navigate to the Spring tab in the WL Admin UI) we still see the following message in the WL console "This application does not use the Spring Framework or Spring MBean integration is not enabled." and no errors or messages in the log.
Does anyone know if it is possible to get Spring 3 apps working with the WebLogic 10.3.4.0 Spring Console Extension or should I try another route?
Weblogic family 10.3.X supports only Spring Framework 2.5.X

Resources