Skip to content

Commit 99a4632

Browse files
committed
修改Logging示例
1 parent 582fd4e commit 99a4632

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

api-boot-samples/api-boot-sample-logging/src/main/java/org/minbox/framework/api/boot/sample/logging/ExceptionAdvice.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
@ResponseBody
3636
public class ExceptionAdvice {
3737
@ExceptionHandler(Exception.class)
38-
public String exception(Exception exception) {
39-
return "请求异常";
38+
public void exception(Exception exception) {
39+
exception.printStackTrace();
4040
}
4141
}

api-boot-samples/api-boot-sample-logging/src/main/java/org/minbox/framework/api/boot/sample/logging/IndexController.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717

1818
package org.minbox.framework.api.boot.sample.logging;
1919

20-
import com.alibaba.fastjson.JSON;
2120
import lombok.Data;
2221
import org.springframework.beans.factory.annotation.Autowired;
23-
import org.springframework.http.HttpEntity;
24-
import org.springframework.http.ResponseEntity;
2522
import org.springframework.web.bind.annotation.PostMapping;
2623
import org.springframework.web.bind.annotation.RequestBody;
2724
import org.springframework.web.bind.annotation.RestController;
@@ -43,13 +40,11 @@ public class IndexController {
4340
private RestTemplate restTemplate;
4441

4542
@PostMapping(value = "/index")
46-
public String index(@RequestBody User user) throws Exception {
47-
HttpEntity<String> httpEntity = new HttpEntity(JSON.toJSONString(user));
43+
public User index(@RequestBody User user) throws Exception {
44+
/*HttpEntity<String> httpEntity = new HttpEntity(JSON.toJSONString(user));
4845
ResponseEntity<String> result = restTemplate.postForEntity("http://localhost:8080/index", httpEntity, String.class);
49-
System.out.println(result.getBody());
50-
//user.setName("恒宇少年");
51-
//throw new Exception("学习下");
52-
return user.getName();
46+
System.out.println(result.getBody());*/
47+
return user;
5348
}
5449

5550
@Data

api-boot-samples/api-boot-sample-logging/src/main/resources/application.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ spring:
33
name: api-boot-sample-logging
44
#profiles:
55
# active: appoint
6-
logging:
7-
level:
8-
org.minbox.framework.api.boot.plugin.logging: debug
96
server:
107
port: 8080
118

129
api:
1310
boot:
1411
logging:
15-
format-console-log-json: true
12+
format-console-log-json: true
13+
show-console-log: true

0 commit comments

Comments
 (0)