-
Notifications
You must be signed in to change notification settings - Fork 41.2k
logging.path(define in application.yml) doesn't load in logback-spring.xml initially #18306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Things should behave the same with |
It's my fault. But there is another problem. I test the logback in pure Spring Boot project, the config work as i excepted. Once i add Spring Cloud dependency, maybe someting wrong. Still the same config, in the sample ,i add a Eureka dependency,the logback config may occur unexcepted results which generate |
Thanks for the additional information. There are some known problems with Spring Cloud's interaction with Spring Boot's logging system. I suspect that the problem you are seeing is related to spring-cloud/spring-cloud-commons#608. This almost certainly needs to be looked at by the Cloud team, but lets leave this issue here for now and I'll try to determine if this is the same problem as spring-cloud/spring-cloud-commons#608 or a different one. |
OK, thx anyway! public static LogFile get(PropertyResolver propertyResolver) {
String file = propertyResolver.getProperty(FILE_PROPERTY);
String path = propertyResolver.getProperty(PATH_PROPERTY);
if (StringUtils.hasLength(file) || StringUtils.hasLength(path)) {
return new LogFile(file, path);
}
return null;
} If i add some parameters when spring boot application start, eg:
the path value is right value. maybe the load order is wrong. The |
Thanks, that's helped to remind me of exactly what's happening here. This isn't a bug in Boot or Cloud, it's expected behaviour due to Spring Cloud's bootstrap context and its requirements for logging configuration. In short, you need to move the configuration of |
Uh oh!
There was an error while loading. Please reload this page.
I need to configure logback in xml file, so i create
logback-spring.xml
andapplication.yml
. I definelogging.path
in the yml file.then, use the variable in
logback-spring.xml
.As we known from offical document, some other properties are transferred from the Spring Environment to System properties.logging.path
corresponds toLOG_PATH
.then ,i run the application.There will be two log fiile generated, one is in
${logging.path}
directory, the other is in a folder named "LOG_PATH_IS_UNDEFINED" generated in.
.This does not match my expectations.And i try to rename the
application.yml
toapplication.properties
, only one log file generate in the right folder.So as the document says:In other words,
logback-spring.xml
will load afterapplication.properties
. But why i change the properties to yml file, the results will be different? So i think maybe this is a bug.The text was updated successfully, but these errors were encountered: