javayh log starter 说明
杨海吉 edited this page Apr 5, 2020
·
4 revisions
javayh-log-starter 是项目日志处理的核心依赖
使用 @EnableLogging 开启对日志的支持,如: 在新的版本已经废弃了@EnableLogging实现了自动注入
@EnableLogging
@JavayhBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class,args);
}
}
内部默认提供,logback日志收集,将info,error进行分离,并且会有按天输出的log
@SysLog 是提供的注解是日志收集方案
他会记录如下信息:
public class OperationLog {
/**
* 唯一id
*/
private String id;
/*
* 调用时间
*/
private String createTime;
/**
* 日志等级
*/
private Integer level;
/**
* 方法名
*/
private String method;
/**
* 参数
*/
private String args;
/**
* 操作人id
*/
private String userId;
/**
* 操作人
*/
private String userName;
/**
* 日志描述
*/
private String describe;
/**
* 方法运行时间
*/
private Long runTime;
/**
* 调用方ip
*/
private String callerIp;
/**
* 本地ip
*/
private String localHostIp;
}
提供了LogError 日志输出模板示例如下
@Autowired(required = false)
private LogError logError;
@ApiOperation(value = "swagger测试", notes = "测试")
@GetMapping(value = "swagger")
public ResultData getSwagger(){
try {
Integer.valueOf("22m");
return ResultData.success();
} catch (NumberFormatException e) {
logError.logPrint("swagger",e.getStackTrace());
return ResultData.fail();
}
}
......未完待续......
关注 Java有货领取更多资料 联系小编。微信:372787553,带您进群互相学习 左侧小编微信,右侧获取免费资料
- SpringCloud 自定义封装架构https://github.com/Dylan-haiji/javayh-platform
- Java 设计模式学习代码 https://github.com/Dylan-haiji/design-pattern
- SpringCloud学习代码: https://github.com/Dylan-haiji/javayh-cloud
- AlibabaCloud学习代码:https://github.com/Dylan-haiji/javayh-cloud-nacos
- SpringBoot+Mybatis 多数据源切换:https://github.com/Dylan-haiji/javayh-boot-data-soure
- Redis、Mongo、Rabbitmq、Kafka学习代码: https://github.com/Dylan-haiji/javayh-middleware
- SpringBoot+SpringSecurity实现自定义登录学习代码:https://github.com/Dylan-haiji/javayh-distribution