-
Notifications
You must be signed in to change notification settings - Fork 40.2k
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
Ability to customize log file name when logging.path is set #16231
Comments
I think this would be a generally useful feature. Let's see what the rest of the team thinks. |
This sounds useful to me too.
This approach won't be possible as logging configuration is needed before any beans are available. |
Depending on the |
in our case, we created a an extra application listener and registered it under:
the content of the listener was something along:
and the order of the listener was: the main motivation for the above was to have a property Since this is a breaking change with existing semantics and i think in |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I believe this ticket is no longer required. Using |
There is still in my opinion a somewhat misleading behavior with They are mutually exclusive. It's either the name (which can actually also be an absolute path), or the path (which then uses a default file name). But you cannot use a combination of both, for instance to set an output directory with Wouldn't it make sense to support this? Or at least mention it in the docs and issue a warning if people configure both properties? |
With the current implementation, when
logging.path
is set to some value andlogging.file
is not set, the logging file name is alwaysspring.log
.spring-boot/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java
Lines 105 to 108 in c115ee1
spring-boot/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LogFile.java
Lines 117 to 122 in c115ee1
I want to be able to set
logging.path
for several microservices at once, using environment variable for example:This works, but all services start to write their logs into signle
/var/log/services/spring.log
file.To prevent this, I added custom
logback-spring.xml
to each application and also onelogback-base.xml
into common module (that all microservices depend on).I added these lines into
logback-base.xml
:This is how
logback-spring.xml
looks in each application:The idea is to store all logs in the same path, but each log file have it's own name, based on
spring.application.name
.But this doesn't work when only
logging.path
is set, becauseLogFile
class always explicitly setsLOG_FILE
system property, using it'stoString()
method and addingspring.log
as file name.Maybe
LogFile
can be enhanced to allow to set some strategy that provides an ability to customize log file name (when it is not explicitly set)? SomeLogFileNameCustomizer
bean or something.Or maybe at least we can make
spring.application.name
to be default log file name if this property is set andlogging.file
is not set? (this is breaking change though, but it can be hidden under some flag).The text was updated successfully, but these errors were encountered: