Is that possible with one config?
- log4j write log to file only when we run project as:java -jar project.jar &
- log4j write log to file and print on console when we run project in eclipse
Is that possible with one config?
Maybe you can have a look at this answer, which seems to describe the same problem.
By using different Spring's profiles, you can switch from one configuration to another very easily, with multiple application.properties
files which contains the property logging.config
pointing on different log4j
config files.
An other option is to use the default Spring Boot's logging mechanism, Logback
which allows you to use the <springProfile>
tag. See here for more details.