enable ssl logs in spring boot application from applicaiton.properties - spring

I wanted to print the SSL handshake debug log, this can be achieved easily by using jvm argument -Djavax.net.debug=ssl:handshake:verbose.
My scenario, need to enable the ssl debug logs on a third-party springboot application image. Is it possible to use the jvm arguments in application.properties to print the SSL debug level log?
I don't have the option to update the Dockerfile to use java -Djavax.net.debug=ssl:handshake:verbose applicaiton.jar .....

I'm not sure you can do exactly that with application.properties but you should be able to get close by adding this:
logging.level.javax.net=TRACE
Have a look at this to see how to set logging levels in application.properties

Related

how disable 'attempting to receive mail from folder' spring integration mail in spring boot

i need to disable "attempting to receive mail from folder " log in spring integration.
Because it writes a lot of logs in catalina.out Tomcat and increases the file size.
See more info in the issue you have raised: https://github.com/spring-projects/spring-integration/issues/3430.
This is not an INFO starting with Spring Integration version 5.4.
As a workaround you can just disable logging for the AbstractMailReceiver class making it on the, let's say, WARN level.
According your tags in the question, you probably use Spring Boot, so its configuration property for the logging may look like this:
logging.level.org.springframework.integration.mail.AbstractMailReceiver=warn
and you won't see that INFO message in logs any more.

Spring Cloud Config Client Actuator Refresh

I have a Client which listens to config server. Config Server is pointing to github. Things work fine with localhost. However when i deploy the application to Kubernetes the Client endpoint to refresh the properties doesn't work properly.
Endpoint (Post) : http://config-client.sbx.com/actuator/refresh
This returns an empty response on Postman "[]" and Response code is 200 OK. I am able to see that the Config server is up and running on K8s.
Any suggestion on what could be wrong?
P.S. I have enabled DEBUG logs but do not see much information there.
Can you verify if the application link has got the hostname and the application name when doing the refresh. Because while doing a refresh in the localhost, it will just be springboot application locally, so there wont be any need for an additional path of application-name. Wherehas when you deploy to a server normally we have to give the path name of the application in addition to the hostname. In tomcat, the URL I use is as below,
http://<hostname>/**<application-name>**/actuator/refresh/
Normally when you hit this URL via postman, it will give you a 200 response with an empty body of []. And then, you should be able to see the below lines in the log files of the client application. [ Also I had the attribute #RefreshScope attribute at the main method of the application just below the #SpringBootApplication attribute to refresh the attributes of the application.]
INFO o.s.c.c.c.ConfigServicePropertySourceLocator.getRemoteEnvironment:249 - Fetching config from server at : http://<hostname>/<Config-server-application-name>/
INFO o.s.c.c.c.ConfigServicePropertySourceLocator.log:168 - Located environment: name=config-client, profiles=[development], label=null, version=ab36989c85922f1c9cf7803fac4, state=null
INFO o.s.c.b.c.PropertySourceBootstrapConfiguration.initialize:112 - Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://<gitlaburl>/<companyname>/config-server.git/config-client-development.yml'}]
INFO o.s.boot.SpringApplication.logStartupProfileInfo:655 - The following profiles are active: development
INFO o.s.boot.SpringApplication.logStarted:61 - Started application in 1.557 seconds (JVM running for 70689.032)
For Kubernetes,
Try using
kubectl apply
(instead of kubectl create configmap.)
To deploy the config map, just run the following command on Kubernetes:
kubectl apply -f config-map.yml
Make sure the name of the config map matches the name of the spring boot application .Also see the below link ,
https://github.com/spring-cloud/spring-cloud-kubernetes/issues/255
Also there is a spring cloud kuberenetes which you can explore as below,
https://cloud.spring.io/spring-cloud-static/spring-cloud-kubernetes/2.0.0.M1/reference/html/#why-do-you-need-spring-cloud-kubernetes

Spring boot microservices doesn't work with Intelij IDEA

I am creating a spring boot microservice project with intelij IDEA.
Currently I have developed three seperate spring boot rest services as customer service, vehicle service and spring cloud config server. Spring cloud config server is pointing to a github repository.
The issue is sometimes above projects take more than 10 minutes to run and sometimes does't run and give an error message as "failed to check application readystate intellij attached provider for the vm is not found". I have no idea why this happens ?
There are two possible causes:
1. IntelliJ IDEA and the Spring application are running in different JVMs.
There is a bug for IntelliJ IDEA regarding that:
https://youtrack.jetbrains.com/issue/IDEA-210665
Here is short summary:
IntelliJ IDEA uses local JMX connector for retrieving Spring Boot actuator endpoint's data by default. However, it could be impossible to get local JMX connector address via attach api if Spring Boot application and IntelliJ IDEA are run by different JVMs. In this case, add the following lines to VM options of your Spring Boot run configuration:
-Dcom.sun.management.jmxremote.port={some_port}
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
As mentioned in the official Oracle documentation, this configuration is insecure. Any remote user who knows (or guesses) your port number and host name will be able to monitor and control your Java applications and platform.
2. Prolonged time to retrieve local hostname
You can check that time using inetTester. Normally it should take only several milliseconds to complete. If it takes a long time then you can add the hostname returned by inetTester to /etc/hosts file like this:
127.0.0.1 localhost winsky
::1 localhost winsky

How do I configure SSL, username and password for Spring Boot Artemis on application.properties?

I'm using Spring Boot 1.3.1 and I can auto-configure my JMS components through application.properties.
As I'm using Artemis as my message broker, I'm using spring-boot-starter-artemis, and as states the documentation in this link, all I have to do is replace the spring.hornetq.* properties and place spring.artemis.* instead.
The problem is that it doesn't show how to configure the username, password and SSL configuration for HornetQ/Artemis. I configured Artemis to use SSL and user/pass authentication like it's shown in here.
Does anyone know what properties can I state to add SSL and user/pass?
Thanks!
Okay, currently the Artemis Spring Boot starter is very basic, it really doesn't support clusters, SSL or client authentication.
Doing a quick look at the starter's source code in GitHub, in the ArtemisConnectionFactoryFactory.java file, at lines 127 and onwards, I will have to add the TransportConstants necessary to configure SSL, authentication, etc.
An example of a more complete connection configuration is in Artemis' test source code, in CoreClientOverTwoWaySSLTest.java, on lines 178 and onwards, there is a really complete connection setup, so to contribute, I have to change the Artemis auto-configuration properties to take the new property options, and add them all to ArtemisConnectionFactoryFactory.java following the example in CoreClientOverTwoWaySSLTest.java
I'll do a fork on the starter, make the modifications, and figure out what bureaucracy is needed to submit a pull request and get it accepted on spring-boot.
Spring Boot does not support such arrangement. Not everything should happen via properties if you ask me but in any case a good way to find out is asking your IDE to auto-complete the keys for that namespace (you'll quickly find out there is nothing related to SSL and security in there). If you don't use an IDE, this appendix should help

Strange behavior with log4j2 configuration

I am working with spring cloud and log4j2 with "all" as level.
I will describe two situations with the same config file, I want to write on a Syslog TCP.
First test: I puth my log4j2 config file in resources folder, then, I start my app and start logging to the syslog.
But I need my configuration on a git, so I expose it to an url.
So here comes the second test:
I changed my bootstrap.yml and and the followind line:
logging: config:
http://xxx.xx.xx.75:3000/admin123/config-repository/raw/master/log4j2.xml
Then, I started my app and it starts to write the logging lines of spring boot in my syslog, but, when I put:
LOGGER.info("printing lalala");
Nothing is writed in the syslog and I can see a [FIN, ACK] beetween client and server on my TCP connections.
So, I understand that the config file is readed from the repository, becouse I can see it in my connections capture and becouse the app starts to log on syslog some lines, but something happend after that to close connection and write no more.
I can`t understand what is happening.
You must add the path of the logging.config on the application.yml not the bootstrap.yml and it works.

Resources