question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

/tmp/spring.log file is generating on spring boot service startup e

See original GitHub issue

Hi, I am using spring boot 1.59 version.

I have logback-spring.xml with proper configurations still spring boot application is generating /tmp/spring.log file on application start up.

Below are my logback-spring.xml configurations.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<include resource="org/springframework/boot/logging/logback/base.xml"/>
	<jmxConfigurator/>
	
	<property name="CONSOLE_LOG_PATTERN"
        value="%d{MM/dd/yyyy HH:mm:ss.SSS XXX} ${LOG_LEVEL_PATTERN:-%5p} ${PID:- } -- [%thread] %logger{60} : %msg%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>

	<!-- Appender to log to file -->
	<springProfile name="local,bamboo">​
	<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>logs/service.log</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
		  <!-- daily rollover -->
		  <fileNamePattern>logs/service.%d{yyyy-MM-dd}_%i.gz</fileNamePattern>
		  <timeBasedFileNamingAndTriggeringPolicy
			  class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
			  <!-- or whenever the file size reaches 10MB -->
			<maxFileSize>10MB</maxFileSize>
		  </timeBasedFileNamingAndTriggeringPolicy>
		  <!-- keep 7 days' worth of history -->
		  <maxHistory>7</maxHistory>
		</rollingPolicy>
		<encoder>
			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
			<charset>utf8</charset>
		</encoder>
	</appender>
	<root >
		<appender-ref ref="file" level="INFO" />
	</root>
​	</springProfile>
	<springProfile name="development,qa1,qa4,pp,prod">​
	<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
		<file>/apps/services/logs/inventory/service.log</file>
		<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
		  <!-- daily rollover -->
		  <fileNamePattern>/apps/services/logs/inventory/service.%d{yyyy-MM-dd}_%i.gz</fileNamePattern>
		  <timeBasedFileNamingAndTriggeringPolicy
			  class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
			  <!-- or whenever the file size reaches 10MB -->
			<maxFileSize>10MB</maxFileSize>
		  </timeBasedFileNamingAndTriggeringPolicy>
		  <!-- keep 7 days' worth of history -->
		  <maxHistory>7</maxHistory>
		</rollingPolicy>
		<encoder>
			<pattern>${CONSOLE_LOG_PATTERN}</pattern>
			<charset>utf8</charset>
		</encoder>
	</appender>
	<root >
		<appender-ref ref="file" level="INFO" />
	</root>
​	</springProfile>

</configuration>

Please suggest some fix

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wilkinsonacommented, Mar 20, 2018

Thanks for the sample. Your logback-spring.xml is including org/springframework/boot/logging/logback/base.xml. That, in turn, includes Boot’s default file appender configuration which writes to /tmp/spring.log by default.

0reactions
wilkinsonacommented, Mar 21, 2018

The replacement should be whatever is appropriate for how you want your logging to be configured and that doesn’t include a file appender that logs to /tmp/spring.log by default. Only you can know what that is and only you know what your requirements are.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Boot uses /tmp/spring.log file during testing
In my Spring Boot application, I have added <property name="LOG_TEMP" value="./logs"/> to src/test/resources/logback-test.xml :
Read more >
Logging in Spring Boot - Baeldung
Learn which beans are automatically configured in your Spring Boot application by generating an auto-configuration report during startup.
Read more >
Spring Boot Reference Documentation
Try the How-to documents. They provide solutions to the most common questions. Learn the Spring basics. Spring Boot builds on many other Spring...
Read more >
Configuring Logging - Quarkus
Internally, Quarkus uses JBoss Log Manager and the JBoss Logging facade. You can use the JBoss ... An example is shown in File...
Read more >
Disable Logback log files in containers - Mobabel
The root cause is spring logback is writing log files into /tmp/ directory as “”spring.log in the containers and the log files are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found