0

I tried to use logging.file.name=springboot.log to set my log file, but no log file would written. But it's very confusing that springboot.txt works. This following is my settings in application.properties:

logging.level.com.demo=trace

# For the following files, I just keep one and comment the others
logging.file.name=springboot.yml   # Works
logging.file.name=springboot.xml   # Works
logging.file.name=springboot.txt   # Works
logging.file.name=springboot.log   # Does not work

logging.file.name=logging/springboot.yml   # Works
logging.file.name=logging/springboot.log   # Does not work
ylqi007
  • 11
  • 1
  • Does this answer your question? [Spring Boot - no log file written (logging.file is not respected)](https://stackoverflow.com/questions/38527175/spring-boot-no-log-file-written-logging-file-is-not-respected) – priyranjan Nov 23 '20 at 12:39
  • No. I read that answer, and I read the document that in Spring version 2.4, `logging.file` is deprecated and it should use `logging.file.name` or `logging.file.path`. I tried both ways, and it confusing that when the log file name ending with `.log`, the spring would not recognize it. – ylqi007 Nov 23 '20 at 17:46

1 Answers1

0

I have just upgraded the dependencies a springboot application that uses multiple profiles and hit a similar issue - for me it works, but fails to work if profiles are involved.

logging.file.name which has been running for at least 6 months now without problems suddenly stopped working after dependency upgrade from 2.3.8 -> 2.4.2.

Thus think looks like a 2.4 issue.

For a temporary fix you could try downgrading - in gradle the following works for me:

plugins
{
    id 'com.github.ben-manes.versions' version '0.36.0'
    id 'org.springframework.boot' version '2.3.8.RELEASE'
}

Having done some further investigation it appears to fail for me because of overrides in the profiles.

So I have two profiles: base and dev which are used together --spring.profiles.active=base,dev

My base sets logging.file.name for the default live. my dev profile overrides this and sets it to ./blah.log.

For me that is not picked up under 2.4.2 and fails, but overrides correctly with 2.3.8.

If you are using multiple profiles this may be the problem.

EDIT: I've raised a big report on Spring Boot on github: https://github.com/spring-projects/spring-boot/issues/25058

barryp
  • 21
  • 3