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

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.

Related

enable ssl logs in spring boot application from applicaiton.properties

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

Google Cloud Trace doesn't correlate logs from Spring Boot applications using Sleuth

I've recently upgraded my applications to Spring Boot 2.4.2, Cloud 2020.0.0, changing Spring Cloud GCP dependencies following the migration guide: https://googlecloudplatform.github.io/spring-cloud-gcp/2.0.0/reference/html/index.html#migration-guide-from-spring-cloud-gcp-1-x-to-2-x
Regarding the applications everything seems to be working fine. I can see calls between the microservices propagating the trace-id headers:
gateway:
2021-01-24 20:18:36.471 DEBUG [gateway,0bc6b9664e6604e2,eb9f834718fe33c9] 1 ---
service1:
2021-01-24 20:18:36.700 DEBUG [service1,0bc6b9664e6604e2,570653ac93add270,true]
In the Google Cloud Trace console I can see that the trace id (0bc6b9664e6604e2) was captured (prefixed with 16 extra 0's) and that it shows both microservices (the first post corresponds to gateway and the third call correspons to service1:
However notice the message "No logs found for this trace".
Also the Trace Logs View link complaints about it:
If I open the link it just looks by timestamp, not using the correlation trace id.
The funny thing is if I look for a log statement directly in the GCP Logging view, the trace id is there:
I can then run a GCP Logging query to find all the logs correctly:
Apparently everything seems to be OK. Could you tell why GCP Trace isn't able to correlate with GCP Logging?
For the logs to appear correlated with tracing you need to add the stackdriver log dependency (I think it only works if your log implementation is logback).
Check https://cloud.spring.io/spring-cloud-gcp/reference/html/#integration-with-logging

How to pass Camel VM messages between multiple Spring Boot applications in Tomcat

We have an application stack, deployed in Tomcat, that consists of several Spring Boot applications. As part of our operations, we want to send some messages to a vm endpoint, where a camel route will consume those messages and then publish them to a JMS topic for any of the other Spring Boot applications that are interested in messages on that topic.
When I start the application stack, there are three spring boot apps that utilize camel, and I see camel start properly in the logs. But when one of the apps sends a message to the vm endpoint, the route that consumes from that endpoint and routes the messages to the jms topic does not seem to get that message. I have placed the camel-core jar in my tomcat lib directory. In the spring boot maven plugin configuration, I have specified an exclusion of the camel-core jar. Oddly enough, that jar is in the WEB-INF/lib of the war anyway! So I have stopped Tomcat, removed that jar from the exploded war, and restarted Tomcat, but that does not change the behavior of the messaging.
Here are the versions that we are using:
Spring Boot 2.3.1
Camel 3.4.2
Tomcat 8.5.5
The first spring boot app that links everything together, with the camel route that consumes from the vm endpoint and produces that message on the jms topic is our "routing engine". It uses camel-spring-boot-starter, spring-boot-starter-artemis, camel-vm-starter, artemis-jms-server and camel-jms-starter. Its RouteBuilder's configure method looks like this:
from("vm:task")
.log(LoggingLevel.WARN, "********** Received task message");
.to("jms:topic:local.private.task")
.routeId("taskToJms");
The app that produces messages to the vm endpoint uses camel-spring-boot-starter and camel-vm-starter. In that app, it has a #Service class that receives a ProducerTemplate that is auto-wired in the constructor. When the application invokes this component to send the message, I see a line in the logs that says
o.a.c.impl.engine.DefaultProducerCache (169) - >>>> vm://task Exchange[]
so it appears that the message is being produced and sent properly to the vm endpoint. However, I see no indication that it has been received/consumed in the routing engine's camel route, since the route's log line is not logging anything, and since I see no other indications of receiving the message in the log. The strange thing is that I am not getting the error of not having any consumers on the vm:task endpoint that I was getting before I put the camel-core jar in tomcat's lib directory.
Am I doing anything obviously wrong? How can I get the spring boot maven plugin to really exclude camel-core? And why are the messages (sent to the vm endpoint) not being consumed by the route in the routing engine? Thanks in advance for any help.
Edit: I was able to keep camel-core out of the war files by adding an exclusion to the configuration of the war plugin, but I was still not able to consume the message on the vm endpoint.
I will post the answer, or at least "an" answer, for anyone who might have found themselves in the puzzling situation that I found myself in.
In short, the answer is that it is best to avoid trying to send VM messages across separate contexts within one big JVM like Tomcat. Instead, use something like JMS. I used Artemis, and I stood up an embedded broker in one of the spring boot apps in tomcat. In other apps (that will be clients), I needed to connect to the embedded artemis server, which requires that you add a #Configuration class (in the module that stands up the embedded broker) that implements ArtemisConfigurationCustomizer:
#Configuration
public class ArtemisConfig implements ArtemisConfigurationCustomizer {
#Override
public void customize(final org.apache.activemq.artemis.core.config.Configuration configuration) {
configuration.addConnectorConfiguration("nettyConnector", new TransportConnfiguration(NettyConnectorFactory.class.getName()));
configuration.addAcceptorConfiguration(new TransportConfiguration(NettyAcceptorFactory.class.getName()));
}
}
That lets your other stuff connect to the embedded Artemis broker. Also, you do not have to worry about upgrading camel-core jars in your tomcat shared lib folder when you upgrade camel to a different version. It's good to keep things simple for maintenance purposes!
Anyway, I hope this helps somebody else who might find themselves here someday.

How to disable Atomikos logfile when running Spring Boot with Atomikos JTA

I am using Spring Boot with Atomikos with embeded undertow server.I will be running my application in docker as a executable jar.We are writing all our logs as Sysout basically we are flushing and not writing any log files.But Atomikos is creating 3 log files when start and run application under my working directory.
How to disable creation of this log files. We should not create any physical log files in Disk.
or
Is there any way I can make these logs will be written in console instead of creating physical file.
Tried below configuration but it's not working.
com:
atomikos:
icatch:
enable_logging=false
You should run with -Dcom.atomikos.icatch.enable_logging=false as Atomikos itself does not read your application.yml so it will not read properties from there. Spring doesn't set this property either. A bit warning though, right from Atomikos documentation:
Specifies if disk logging should be enabled or not. Defaults to true.
It is useful for JUnit testing, or to profile code without seeing the
transaction manager's activity as a hot spot but this should never be
disabled on production or data integrity cannot be guaranteed.
Transaction logs are as important as data as they're used to recover from failures.

turning off spring debug logs

I am using log4j for logging to console as well as file.Setting the threshold to INFO level doesn't prevents debug logs from spring.I have set rootlogger to INFO level as well.
I guess my spring logs are coming from my dependencies.M not able to get rid of them by setting level OFF for spring logs as well.Spring logs are using commons logging.How can I turn off these logs in my XML file?

Resources