I'm working in a spring-boot project (version 1.5.1) and using logback. My application.properties
has the following log settings:
logging.level.=info
logging.level.org.acme.myapp=info
logging.file=${catalina.home}/logs/AppLogFile.log
When the application logs something this is written to the specified AppLogFile.log
and also to catalina.out
:
==> AppLogFile.log <==
2017-04-13 13:37:33.102 DEBUG 4646 --- [http-nio-8080-exec-25] c.l.c.c.controller.IndexPage : isAllowedToSeeContent: Homebase: MOCKBASE
==> catalina.out <==
2017-04-13 13:37:33.102 DEBUG 4646 --- [io-8080-exec-25] c.l.c.c.controller.IndexPage : isAllowedToSeeContent: Homebase: MOCKBASE
==> AppLogFile.log <==
2017-04-13 13:37:33.108 DEBUG 4646 --- [http-nio-8080-exec-25] c.l.c.c.controller.MedlistService : MedlistService::isControlDay 2017-04-13, true
==> catalina.out <==
2017-04-13 13:37:33.108 DEBUG 4646 --- [io-8080-exec-25] c.l.c.c.controller.MedlistService : MedlistService::isControlDay 2017-04-13, true
This seems to be additivity
Problem. Is it really necessary to provide logback.xml like mentioned in here: howto-configure-logback-for-logging?
Or is there a more direct way?
Update:
Even if I follow the recommendation from the howto and add a logback-spring.xml
to my classpath:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}/}spring.log}" />
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
<root>
<appender-ref ref="FILE" />
</root>
</configuration>
I get the following errors (en masse):
17:50:01.267 [localhost-startStop-1] DEBUG org.springframework.jndi.JndiPropertySource - JNDI lookup for name [LOGGING_patternLevel] threw NamingException with message: Name [LOGGING_patternLevel] is not bound in this Context. Unable to find [LOGGING_patternLevel].. Returning null.
17:50:01.267 [localhost-startStop-1] DEBUG org.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/LOGGING_patternlevel]
Setting logging.pattern.console=
to an empty string, seems to do the trick - BUT is this really the right solution?
As the target tomcat is NOT under my control and my application is not the only one on the server, I've decided to disable the console logging by setting the logging.pattern.console=
to an empty string.
The answer from Olaf Kock, I'm sure, is also valid, see the Considerations for production usage paragraph - but I have to admit I failed to get it working - Therefor I could not test it :(