I have created a Spring Boot application with version 1.2.8 where I'm using an external Tomcat Container for deployment.
In the deployment archive .jar
I have a logback.xml
with default values as follows:
<configuration scan="true">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<charset>utf-8</charset>
<Pattern>%d{HH:mm:ss.SSS} [%-4p] %-4c \n\t%m%n</Pattern>
</encoder>
</appender>
<appender name="ROLLING" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- rollover daily -->
<fileNamePattern>${user.dir}/logs/app-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 100MB -->
<maxFileSize>5MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<maxHistory>10</maxHistory>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} - [%-30logger{0}] - [%-5p] -%X{traceInfo} \n\t%m%n</pattern>
</encoder>
</appender>
<root level="INFO" >
<appender-ref ref="ROLLING"/>
</root>
</configuration>
Now in my external Tomcat I have my application.properties
and logback
in my $CATALINA_BASE/lib
folder.
Since these files are already on the classpath. The logging.config
property by default is set to classpath:logback.xml
. So the logback.xml located there should be visible but it is ignored.
I have also tried an absolute path
logging.config=C:\\\\myuser\\\\tomcat\\\\lib\\\\logback.xml
which is also ignored.
I'm trying for example to override logging level with the external logback.xml
like this:
<configuration scan="true">
<root level="DEBUG" >
<appender-ref ref="CONSOLE"/>
<appender-ref ref="ROLLING"/>
</root>
</configuration>
Any ideas?
In your project source ensure that logback.xml is in a classpath folder.
So if your project is a web project named sampleweb your logback.xml should go
src/main/resources
You should not have to configure tomcat externally.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.