2017-09-29 57 views
0

在我的應用程序性能我已經寫了下面的記錄記錄使用彈簧啓動sl4j

logging.level.com.intro.dmp=INFO 
logging.level.org.springframework.web=ERROR 
logging.level.com.intro.dmp=ERROR 
logging.file=application.log 

和我的應用程序是下面的,但它也沒有創造控制檯,而顯示任何日誌文件。什麼是我缺少在這裏,它是閱讀應用程序屬性

@SpringBootApplication(scanBasePackages = "com.intro") 
@PropertySource("file:src/main/resources/application.properties") 
public class Application { 

    public static void main(String[] args) { 
    SpringApplication.run(Application.class, args); 
    logger.debug("--Application Started--"); 
    logger.error("Check the main Articles"); 
    logger.info("Checking files "); 
} 

} 

回答

0

兩個變化將解決您的問題:

  1. application.properties文件,你需要提供報價到文件名。即:logging.file='application.log'
  2. 您可以刪除@PropertySource註釋。默認情況下,Spring Boot將在src/main/resources/處查找application.properties文件。
+0

不工作我的身份 –

+0

@HimanshuKhandelwal好吧。然後試試第一點。在代碼中保留「@ PropertySource」。 –

+0

不工作,我需要包含logback.xml,我使用的是最新版本的spring啓動? –