Springboot logging level disable DEBUG logging on Gitlab - spring-boot

On our bootstrap.yml of our test units
logging:
level:
com.xxxx: INFO #from DEBUG
However the debugging still shows on Gitlab but it the INFO logging works when i run it local
Why is Gitlab still show DEBUG level logging?
Note that these are flowable debug logs and i have tried logging.level.org.fowable = info but that doesn't work

The solution is to use logback-test.xml and place in within resource folder of each module
<configuration>
<logger name="org.springframework" level="INFO"/>
##additional entries
</configuration>

Related

How to add default logback.xml to spring boot project?

I have created a new spring boot project using spring initializer with spring-boot-starter-web as a starter project.I am able to use logback for logging but am unable to find default logback.xml in the project.I tried to search out but could not find reference to default file on logback documentation as well. I am looking to customize the logback file to use custom appender.
You can customize by using your application.yml, like this :
logging:
level:
root: WARN
org.springframework.security: DEBUG
org.springframework.web.servlet: INFO
org.springframework.jmx: INFO
org.springframework.cloud.config.client: INFO
org.springframework.cloud.context: INFO
org.hibernate: INFO
org.hibernate.sql: DEBUG
pattern:
console: '%date{HH:mm:ss.SSS} [%-5level] %-65logger - %msg%n'
file: '%date{HH:mm:ss.SSS} [%-5level] %-65logger - %msg%n'
file: D:/logs/my-log.log
And define for each profile

spring boot logback not logging my application logs

Need help... what am I doing wrong here???
I believe it does read the path and file name from application.properties file. But I don't think it reads the logback.xml or logback-spring.xml
I did some research and found many questions/answers. But I think everyone says to put the logback xml in resources and give the path and file name in application.properties. I know it is simple, but missing something somewhere...
Thanks in advance!!
application.properties
# ===============================
# LOGGING
# ===============================
# log configuration -- update config location as needed
#logging.config=/logback-spring.xml
#logging.file=/logs/iqs-service.txt
logging.path=/logs
logging.file=${logging.path}/log.log
logging.pattern.file=%d{dd-MM-yyyy HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M - %msg%n
Content of log file (log.log.0):
[2018-12-10 15:54:41.999] - 10828 INFO [main] --- org.apache.catalina.core.StandardService: Starting service Tomcat
[2018-12-10 15:54:42.002] - 10828 INFO [main] --- org.apache.catalina.core.StandardEngine: Starting Servlet Engine: Apache Tomcat/8.5.14
[2018-12-10 15:54:42.257] - 10828 INFO [localhost-startStop-1] --- org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]: Initializing Spring embedded WebApplicationContext
[2018-12-10 15:54:46.551] - 10828 INFO [http-nio-19917-exec-1] --- org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]: Initializing Spring FrameworkServlet 'dispatcherServlet
Log statements in my java method - This never prints in the log
log.info("init(): [" + modelId + "]");
log.error("init(): [" + modelId + "]");
As far as I can tell the only thing I think that will kill it are these lines:
logging.path=/logs
logging.file=${logging.path}/log.log
I believe that if you include both, Spring Boot will ignore both of them. So I'd try removing one of those, and seeing if that helps.
As another thing (but I don't think it contributes to this problem), Spring recommends that you have just a logback-spring.xml file, not logback.xml (and definitely not both).

Spring-Jboss: Security debugging is enabled

I have a Spring (4.1.7) MVC application running on Jboss (7.1.3).
In the server.log, I have the following message
16:06:21,564 WARN [org.springframework.security.config.debug.SecurityDebugBeanFactoryPostProcessor] (MSC service thread 1-7)
********************************************************************
********** Security debugging is enabled. *************
********** This may include sensitive information. *************
********** Do not use in a production system! *************
********************************************************************
I want to change the log level of spring security to INFO.
I tried these 2 lines in my log4j.properties
log4j.category.org.springframework.security = INFO
log4j.logger.org.springframework.security=INFO
but none of them works.
I also modified the config of Jboss (standalone.xml) by adding these lines
<logger category="org.springframework.security">
<level name="INFO"/>
</logger>
but the message still appears in the server log.
Can you please tell me how can we change the log level of spring?Thanks
It's because that's a warning message. If you set the level to INFO it will print INFO and higher levels.
If you don't want to see that specific message you could add a category for org.springframework.security.config.debug.SecurityDebugBeanFactoryPostProcessor and set it to ERROR. I'm not sure what other messages you'd be missing though.

Spring Boot : LOGBack custom fields in every log statement

Thought of sharing the below work as I struggled to find this info:
Requirement is to put the business correlation id(AccCode and Mac) in every log statement. This can be done by using Mapped Diagnostic Context(MDC)..
No need to understand how LOGBack appender->Encoder->Layout work.
Spring boot log4j.properties has below pattern:
LOG_LEVEL_PATTERN=%5p
LOG_PATTERN=[%d{yyyy-MM-dd HH:mm:ss.SSS}] boot%X{context} - ${PID} ${LOG_LEVEL_PATTERN} [%t] --- %c{1}: %m%n
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=${LOG_PATTERN}
Override LOG_LEVEL_PATTERN from application.properties with custom fields:
logging.pattern.level=AccCode:%X{AccCode} Mac:%X{Mac} %5p
Please note, now we have two extra fields defined into the layout. AccCode and Mac. Value for these new fields need to be provided using the MDC:
MDC.put("AccCode", "46014" );
MDC.put("Mac", "2025b9bcf");
Then all the log statements would have AccCode and Mac as below:
2016-09-12 09:11:37.574 **AccCode:46014** **Mac:2025b9bcf** DEBUG 9724 --- [main] c.c.p.sph.http.client.SphApAdminClient : Loging out from Sph

Jenkins slave running Maven gives log4j warning

I'm using Jenkins, and I have a Windows machine set up as a slave worker. I have a Maven-based project that runs on the slave. The build works correctly, but I get a warning from log4j about it not being initialized. I'd like to scratch that itch and remove the warning, but I don't know how.
I'm not very familiar with log4j. I do understand I could set a system property to tell it where to find a config file, but I don't know where in the Jenkins pipeline that property should be set or how. It looks like the warning comes before Maven starts but after the slave begins the job.
Here's the snippit of console output:
Parsing POMs
[MyTest] $ java -cp C:\jenkins\maven3-agent.jar;C:\jenkins\tools\Maven\Maven\boot\plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main C:\jenkins\tools\Maven\Maven C:\Users\waisbrot\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\28\5c50da9c-2d1a9aef C:\jenkins\maven3-interceptor.jar 49210
<===[JENKINS REMOTING CAPACITY]===>channel started
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven: -B -f C:\jenkins\workspace\MyTest\pom.xml test
[INFO] Scanning for projects...
I'm not particularly proud of this, but I wasn't interested in any of that idle chatter, so I suppressed it by doing
jar uf <path to maven3-agent-1.2.jar>/maven3-agent-1.2.jar log4j.xml
where log4j.xml contains
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<root>
<level value="off"/>
</root>
</log4j:configuration>
NB: the jar command must be executed as shown, with log4j.xml in the current directory.
Just provide a log4j.properties or a log4j.xml with valid contents in the classpath. See the log4j documentation for details

Resources