Commit 893ef7d2fb0337e5d27a14e62c8348aa08f9cddb
1 parent
e2fd0d4f
修改日志存放位置
Showing
3 changed files
with
8 additions
and
3 deletions
src/main/java/com/cnlive/shenhe/logging/LoggingWSServer.java
| ... | ... | @@ -30,6 +30,9 @@ public class LoggingWSServer { |
| 30 | 30 | @Value("${spring.application.name}") |
| 31 | 31 | private String applicationName; |
| 32 | 32 | |
| 33 | + @Value("${spring.application.home}") | |
| 34 | + private String applicationHome; | |
| 35 | + | |
| 33 | 36 | /** |
| 34 | 37 | * 连接集合 |
| 35 | 38 | */ |
| ... | ... | @@ -53,7 +56,8 @@ public class LoggingWSServer { |
| 53 | 56 | BufferedReader reader = null; |
| 54 | 57 | try { |
| 55 | 58 | //日志文件路径,获取最新的 |
| 56 | - String filePath = System.getProperty("user.home") + "/log/" + new SimpleDateFormat("yyyyMMdd").format(new Date()) + "/"+applicationName+".log"; | |
| 59 | +// String filePath = System.getProperty("user.home") + "/log/" + new SimpleDateFormat("yyyyMMdd").format(new Date()) + "/"+applicationName+".log"; | |
| 60 | + String filePath = applicationHome + new SimpleDateFormat("yyyyMMdd").format(new Date()) + "/"+applicationName+".log"; | |
| 57 | 61 | |
| 58 | 62 | //字符流 |
| 59 | 63 | reader = new BufferedReader(new FileReader(filePath)); | ... | ... |
src/main/resources/application.properties
| ... | ... | @@ -38,7 +38,7 @@ server.port=82 |
| 38 | 38 | |
| 39 | 39 | #logback\u65e5\u5fd7\u4e2d\u4f7f\u7528 |
| 40 | 40 | spring.application.name=cnlive_shenhe_test |
| 41 | -#spring.application.home=/usr/local/test_cnlive_shenhe/cnlive_shenhe/log | |
| 41 | +spring.application.home=/usr/local/test_cnlive_shenhe/cnlive_shenhe/log | |
| 42 | 42 | |
| 43 | 43 | sync_users_api=http://api.cnlive.com/open/api2/inner2/shenhe/getuser |
| 44 | 44 | sync_users_app_key=314a9dd4-a9b7-4c12-bbbe-1150a36491ae | ... | ... |
src/main/resources/logback-spring.xml
| ... | ... | @@ -6,7 +6,8 @@ debug:当æ¤å±žæ€§è®¾ç½®ä¸ºtrue时,将打å°å‡ºlogback内部日志信æ¯ï¼Œå |
| 6 | 6 | --> |
| 7 | 7 | <configuration scan="false" scanPeriod="60 seconds" debug="false"> |
| 8 | 8 | <!--日志文件主目录:这里${user.home}ä¸ºå½“å‰æœåŠ¡å™¨ç”¨æˆ·ä¸»ç›®å½•--> |
| 9 | - <property name="LOG_HOME" value="${user.home}/log" /> | |
| 9 | +<!-- <property name="LOG_HOME" value="/usr/local/test_cnlive_shenhe/cnlive_shenhe/log" /> --> | |
| 10 | + <springProperty scope="context" name="LOG_HOME" source="spring.application.home"/> | |
| 10 | 11 | <!-- 定义日志文件åç§° --> |
| 11 | 12 | <!-- <property name="appName" value="appName" source="spring.application.name"></property> --> |
| 12 | 13 | <!--日志文件å称:这里spring.application.name表示工程åç§°--> | ... | ... |