Skip to content

Commit 0b9503c

Browse files
author
nishant
committed
logger
1 parent e637633 commit 0b9503c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/com/example/demo/DemoApplication.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.web.bind.annotation.GetMapping;
66
import org.springframework.web.bind.annotation.RestController;
7+
import org.slf4j.Logger;
8+
import org.slf4j.LoggerFactory;
9+
710

811
@SpringBootApplication
912
@RestController
1013
public class DemoApplication {
11-
14+
Logger logger = LoggerFactory.getLogger(DemoApplication.class);
1215
@GetMapping("/")
1316
public String home() {
1417
return "Hello World!";
@@ -23,7 +26,8 @@ public String home22() {
2326
}
2427
catch(Exception ex)
2528
{
26-
ex.printStackTrace(); //this will get "Some required files are missing"
29+
logger.error("An exception occurred!", ex);
30+
//ex.printStackTrace(); //this will get "Some required files are missing"
2731
}
2832
return "hello error";
2933

0 commit comments

Comments
 (0)