Spring boot - how to reduce log output from specific library? - spring-boot

I am using the library net.iakovlev.timeshape.TimeZoneEngine and it is spewing a lot of [DEBUG] messages on startup which seems to be the default behaviour.
In application.yml I should be able to control logging level with but that's not working somehow.
logging:
level:
net.iakovlev.timeshape: ERROR
Isn't this the correct way to do so?

Set your log configuration file, and add something like this :
...
<logger name="net.iakovlev.timeshape" level ="ERROR" additivity="false">
<!-- YOUR APPENDER -->
<appender-ref ref="CONSOLE" />
</logger>
...

Related

Recursive logging from [org.apache.Kafka.clients.networkclient] for appender

I have a spring boot application using log4j2 for logging and want to use Kafka appender . Mentioned all properties in right format in log4j2.xml and properties of Kafka topic ,server and groupid in application.properties
But each time I start my application am facing a error in console logs saying as below
Kafka-producer-network-thread | producer-1 WARN recursive logging from [org.apache.Kafka.clients.networkclient] for appender [mykafkaappendername]
This warning means you should configure your org.apache.kafka Logger to send log events to some other Appender.
You should probably have a proper Log Appender defined and should refer from your logger with appropriate log level and additivity, something like this
<logger name="com" level="INFO" additivity="false">
<appender-ref ref="appenderName"/>
</logger>
<root level="logLevel">
<appender-ref ref="appenderName"/>
</root>

Logback logging levels are ignored, Spring Boot 2.1.0

I have been using logback successfully for a while in my Spring Boot applications using Spring Boot 1.5.x and 2.1.x. I use logback-spring.xml on the classpath to configure logback.
After a recent build using Spring Boot version 2.1.0.BUILD_SNAPSHOT, the output to my logs suddenly changed. I am now getting all DEBUG and TRACE levels on all packages (other than my own) e.g. on startup I am swamped with org.apache.* and org.springframework.* logging.
When I try to adjust the logging levels for these packages, the levels are ignored. I.e. the following does not work in limiting the logging:
<logger name="org.apache" level="ERROR"/>
<logger name="org.springframework" level="ERROR"/>
Adjusting the logging level of the root logger also has no affect.
I have ensured that debug=false in application.properties
Note that the log levels for my application still work.
<logger name="com.myapp" level="debug">
<appender-ref ref="MY_FILE" />
<appender-ref ref="CONSOLE" />
</logger>
So it appears that my configuration is indeed found and used to configure logback, but the logging levels for some packages are broken or being overridden?
I have just tested with Spring Boot 2.0.3.RELEASE and I do not have the problem with this version.

Setting level to a logger in spring-boot

In logback-spring.xml file of a project that is new to me I see this configuration
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
......
</appender>
<logger name="com.myproject.myclass" level="${APP_LOGGING_LEVEL:-INFO}" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
As far as I understand, all logs from com.myproject.myclass class will be sent to <appender name="STDOUT"> that is console.
Could someone explain me what will be the level of this log with this config level="${APP_LOGGING_LEVEL:-INFO}"? In documentation I see only constants like WARN, DEBUG, etc
In Spring ${APP_LOGGING_LEVEL:-INFO} means APP_LOGGING_LEVEL is a dynamic variable. The value for which can be set from properties file or from command line when running the project or from any other place accessible. If not set whatever after : is selected.
In your case if not set INFO is selected

Possible: Override logback logging level with environment variables

I currently have the following logger defined in my logback.xml:
<logger name="Event" level="INFO" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
Is it possible to override the level here using an environment variable? I am using SpringBoot.
I have tried having these defined as ENV variables:
LOGGING_LEVEL_ROOT=ERROR
LOGGING_LEVEL_EVENT=ERROR
LOGGER_LEVEL_EVENT=ERROR
However none of these worked.
Spring Boot supports springProfile extension for the logback configuration file:
<springProfile name="test"> </springProfile>
Documentation
Also there is another way to do it using LoggingApplicationContextInitializer.

Suppress internal logging from Gradle tooling API

When I use the Gradle tooling API in my custom plugin, I get a lot of noise at the console, e.g.:
Creating ClassLoader af47d36a-0f9f-40d2-8bc3-b32738455061 from system and [org.gradle.internal.classloader.FilteringClassLoader#5aa153ee].
Creating ClassLoader 0088fcb2-a08b-48a1-92f9-94d18f846340 from org.gradle.internal.classloader.MutableURLClassLoader$Spec#62f1c342 and [org.gradle.internal.classloader.FilteringClassLoader#5aa153ee].
(and half a dozen similar lines), and
Tooling API is using target Gradle version: 2.0.
Connected to the daemon. Dispatching Build{id=b0b916a3-d386-4088-8d00-d321216263ca.1,currentDir=/home/dmoles/Projects/makeproject-new} request.
How can I suppress this? I tried configuring SLF4J to use Log4J in my plugin's build.gradle (I have no idea what it uses by default) and setting an ERROR-level appender for org.gradle in my log4j.xml, but that appears to do nothing.
I then tried adding the following Logback configuration file to my plugin's src/main/resources --
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"/>
<logger name="org.gradle.tooling" level="ERROR" additivity="false">
<appender-ref ref="STDOUT"/>
</logger>
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
-- rebuilt the plugin, refreshed dependencies in the project that uses the plugin, and invoked it again, but I still get all the tooling DEBUG output.
I also tried programmatically reconfiguring the log level but ran into classloader issues:
The following classes appear as argument class and as parameter class, but are defined by different class loader:
ch.qos.logback.classic.Level (defined by 'java.net.URLClassLoader#56464aa5' and 'org.gradle.internal.classloader.MutableURLClassLoader#7e41986c')

Resources