1、添加依赖
org.projectlombok lombok
2、在resources目录下添加logback-spring.xml文件
debug
%date [%-5p] [%thread] %logger{60} [%file : %line] %msg%n
UTF-8
E:/log/springboot-logback.log
%date [%-5p] %thread %logger{60} [%file : %line] %msg%n
E:/log/springboot-logback.log.%d{yyyy-MM-dd}.log
30
3、使用,在controller中这样使用
package com.bjpowernode.springboot;
import com.bjpowernode.springboot.servlet.StudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@Slf4j
public class StudentController {
@Autowired
private StudentService studentService;
@RequestMapping(value = "/student/count")
public @ResponseBody String studentCount(){
log.info("查询当前学生总人数");
Integer studentCount = studentService.queryStudentCount();
return "学生总人数为:" + studentCount;
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)