Commit 2dfd0516b1de524781b8f597d1c20d4dd3e751a7
1 parent
afac5507
1.管理员controller添加日志级别变更功能
Showing
1 changed file
with
27 additions
and
11 deletions
src/main/java/com/bsth/controller/realcontrol/AdminUtilsController.java
| 1 | 1 | package com.bsth.controller.realcontrol; |
| 2 | 2 | |
| 3 | +import java.text.SimpleDateFormat; | |
| 4 | +import java.util.Date; | |
| 5 | +import java.util.HashMap; | |
| 6 | +import java.util.List; | |
| 7 | +import java.util.Map; | |
| 8 | + | |
| 9 | +import org.slf4j.Logger; | |
| 10 | +import org.slf4j.LoggerFactory; | |
| 11 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 12 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 13 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 14 | +import org.springframework.web.bind.annotation.RestController; | |
| 15 | + | |
| 3 | 16 | import com.bsth.common.ResponseCode; |
| 4 | 17 | import com.bsth.data.directive.DayOfDirectives; |
| 5 | 18 | import com.bsth.data.directive.DirectivesPstThread; |
| ... | ... | @@ -12,18 +25,9 @@ import com.bsth.data.pilot80.PilotReport; |
| 12 | 25 | import com.bsth.data.schedule.DayOfSchedule; |
| 13 | 26 | import com.bsth.entity.realcontrol.ScheduleRealInfo; |
| 14 | 27 | import com.bsth.websocket.handler.SendUtils; |
| 15 | -import org.slf4j.Logger; | |
| 16 | -import org.slf4j.LoggerFactory; | |
| 17 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 18 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 19 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 20 | -import org.springframework.web.bind.annotation.RestController; | |
| 21 | 28 | |
| 22 | -import java.text.SimpleDateFormat; | |
| 23 | -import java.util.Date; | |
| 24 | -import java.util.HashMap; | |
| 25 | -import java.util.List; | |
| 26 | -import java.util.Map; | |
| 29 | +import ch.qos.logback.classic.Level; | |
| 30 | +import ch.qos.logback.classic.LoggerContext; | |
| 27 | 31 | |
| 28 | 32 | /** |
| 29 | 33 | * Created by panzhao on 2017/4/14. |
| ... | ... | @@ -203,4 +207,16 @@ public class AdminUtilsController { |
| 203 | 207 | |
| 204 | 208 | return rs; |
| 205 | 209 | } |
| 210 | + | |
| 211 | + @RequestMapping("/changeLogLevel") | |
| 212 | + public Map<String, Object> changeLogLevel(@RequestParam String level) { | |
| 213 | + Map<String, Object> rs = new HashMap<>(); | |
| 214 | + rs.put("errCode", 1); | |
| 215 | + LoggerContext context = (LoggerContext)LoggerFactory.getILoggerFactory(); | |
| 216 | + context.getLogger("root").setLevel(Level.toLevel(level)); | |
| 217 | + rs.put("errCode", 0); | |
| 218 | + rs.put("errMsg", "成功"); | |
| 219 | + | |
| 220 | + return rs; | |
| 221 | + } | |
| 206 | 222 | } |
| 207 | 223 | \ No newline at end of file | ... | ... |