How to serve up logging files in a html page? - spring

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.

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 use graphite in combination with logstash in a spring boot application?

I'd like to know if there exists some best practice how to chain graphite and logstash in a spring boot application. Should they exchange happen via the log files, or directly or is there some other way?
How would the respective setup look like, i.e. if we user docker and io.fabric maven plugin.

Swagger integration with Logback

I'm setting up my Spring Boot application and I've managed to add API documentation using swagger following this tutorial
http://heidloff.net/article/usage-of-swagger-2-0-in-spring-boot-applications-to-document-apis/
It's all good I can see the endpoints and use the UI to hit them. Now I want to add somehow visibility of my logging file. I'm using logback with rolling file appender. Is it possible to configure swagger to start showing my logs?

How to deploy a spring integration component?

I've developed a spring integration component that is to sit on a server and process messages coming in over an inbound RMI channel do some processing/filtering and then send out some messages over a different RMI channel.
Currently, for testing, I've been running it using a Main class that just loads the context, which sets up the inbound RMI gateway and it's working fine. But I don't think that this is appropriate for a production environment.
What is the best way to deploy this type of project to a server?
If I were working in a .Net I'd be deploying this type of application as a windows service, is that what I should be doing here?
The application that is sending me data is hosted in Tomcat, would it be a good idea to also run this application within the same Tomcat container (Current requirements are for both components to be on the same machine this may change)? And if so how?
I'm currently looking into Spring Boot, am I on the right path?
I think the best would be Spring Boot, as it's made to easily allow running different types of applications. Also, you don't need Tomcat if you can run the same component with a simple Main and not using UI. Spring Boot, also, has a sample using Spring Integration here, so you should be up and running in no time.

Resources