turning off spring debug logs - spring

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?

Related

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 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.

Stackdriver - All logs are mapped as INFO

All my logs ERROR/WARNIN are mapped as INFO at Stackdriver.
I'm using logback and Im running my application in a Kubernetes cluster.
How can I setup my logback to Stackdriver?
Tks
The Stackdriver logging agent configuration for Kubernetes defaults to INFO for any logs written to the container's stdout and ERROR for logs written to stderr. If you want finer-grained control over severity, you can configure Spring to log as single-line JSON (e.g., via JsonLayout1) and let the logging agent pick up the severity from the JSON object (see https://cloud.google.com/logging/docs/agent/configuration#process-payload).
1By default, JsonLayout will use "level" for the log level, while the Stackdriver logging agent recognizes "severity", so you may have to override addCustomDataToJsonMap.
See also GKE & Stackdriver: Java logback logging format?

Integration of fluentd with Java application

I am working on integrating spring boot application with fluentd.
When I use FluentdLogger in the application and source as forward in fluentd config file, I am able to log the entries to log file .
So How to provide log level to log statments in spring boot application, default is every statement is printed to file with tag.
Do I have to use in_tail with logging frameworks which will log to file and fluentd will tail from that file to another file.
OR there is way or appender in logback or logging frameworks in java.

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.

Resources