I am currently using Spring Boot Admin to manage a Spring Boot application. SBA exposes correctly the logs of the application in the tab "Log". As part of transitioning the deployment to Docker I would like to continue forwarding our logs to stdout and ELK, but to stop logging to a rotating log file.
After removing from Spring Boot application.properties file the property "logging.file" I could check that, as expected, the rotating log file was not created. However this configuration change had the side-effect of removing from SBA the "Log" tab exposing the logs.
My question is: is there any way I could still expose logs through Spring Boot Admin without having to have a log file for the application?
Spring Boot admin needs the logfile acuator endpoint. The endpoint needs a file on the disk. It either serves the file from loging.file or endpoint.logfile.external-file.
Here is a simple workaround:
Add a link to a kibana query for the application (or similar) to your info endpoint l. It is rendered as hyperlink in SBA. This would be a convenient way for the users to find the log output.
Related
To give you some context, we have various microservices and a config server where we store store all the application.yml files.
The problem is when some issue happens, we have to temporarily enable logs for every application so that we can trace the activities done by the user. But this creates a hassle as we have to change the log configs.
So we want to enable logging for only certain users (say, when some issue happens and we want to debug) via changing the yml files so we don't have to touch the code or redeploy the application. Basically we are thinking of creating a application-logging.yml file for all the microservices and in this when we mention
logging:
users:
id: 123
level: warn
all the microservices will pick it up and start generating logs only for this user.
How can I implement this in Spring Boot, if its possible?
Put user ID into the thread context then use a MutableThreadContextMapFilter.
You can specify values via a JSON file, which log4j polls periodically to pick up changes.
How can I put into spring boot app properties logback-file.xml and logback-access.xml at the same time? And if I can, logs will write in one file, or in different?
See the available Spring Boot properties.
You will find generic logging.* ones as well as server.tomcat.accesslog.* OR server.jetty.accesslog.* depending on your embedded servlet container.
Core logs will be printed based on logback-spring.xml, and access-logs (logs written whenever someone accesses any of your API's) will be printed based on logback-access.xml.
In application.properties, use logging.* for core/server logs and server.(yourserver).accesslog.* for access logs.
I've been trying to figure out what I'm missing with my RestTemplate setup (particularly OAuth2RestTemplate) so I want to see the logs for debugging. I found one possible solution for it, but nothing about the operation of the RestTemplate gets shown.
What I've done so far is to replace the default Logback logging mechanism in my Spring Boot app by following the configuration shown here. When I run my Spring Boot application after changing the logging dependencies, all I see on the console is the Spring logo (in ASCII) and nothing else. I've already defined a log4j-spring.properties in src/main/resources with the property defined in the previous link.
What else am I missing here? Do I need to run my Spring Boot app in debug mode? If so, how do I do that? Also, how do I set this up using the default Logback mechanism?
I am using Spring Cloud Config Server/Client and the documentation says that the server takes precedence by default over a local application.properties file. If the cloud config server happens to be unavailable the application will retry for some time and then fail to start up correctly. I would like to go around this issue by having the application save the properties fetched from the config server when it starts correctly and therefore when the config server isn't available default to the last set of properties it downloaded. Is this possible? If yes how do I access and save the properties?
I solved this issue by creating a class that implements EnvironmentAware and instantiated it as a spring bean so a property of type Environement get set automatically. I then used environmet.getPropertySources() to get the properties I needed. I then proceeded to write them to file.
I arrived to this solution by examining the code of Spring's actuator and the /env endpoint displays the applications properties.
What is the purpose of Web Service Deployment Descriptor (wsdd) configuration file.
If I didn't configure this file explicitly it doesn't create any issue in my application (as I am using a .jws file to do some web service related processes). But, for the first time the application runs, an error is logged in the error log file. The error is as follows:
"Unable to find config file. Creating new servlet engine config file: /WEB-INF/server-config.wsdd". And when the page refreshes or even the application is re-logged in (still the server is running), there won't be any such error log further times. When I use a sample wsdd file in my application, the error is not at all logged in the error log file. I want to know the purpose of this wsdd file and how to configure it based on our application.
Any suggestions would be appriciated.
Marshal.
Just do a google on "server-config.wsdd".
e.g. http://axis.apache.org/axis/java/integration-guide.html
It looks like your container or framework is generating a default file if you don't specify one, which is useful, but if you wish to add additional customisations such as handlers, security and logging (etc) then you can specify your own file.
It might be best to use a "bare minimum" file so you can customise it later.