当前位置:网站首页>日志级别 和 打印log注意
日志级别 和 打印log注意
2022-07-31 03:16:00 【喀什葛尔的胡杨_】
常用的日志打印 占位符一般用 {} 就可以, 例如
log.info("name is {}", name);
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class HelloWorld {
public static Log log = LogFactory.getLog(HelloWorld.class);
public static void main(String[] argv) {
String test="sdibt";
log.error("this is error:"+test);
log.info("this is info:"+test);
log.debug("this is debug:"+test);
}
}
日志信息中已经给出了类名,根据类名及打印信息可以直接查找到所在的代码
格式: 时间 info 包名.类型 打印日志所在行数, 打印日志信息
2018-05-10 10:46:29,566 ERROR [example.HelloWorld]:10 - this is error:sdibt
2018-05-10 10:46:29,566 INFO [example.HelloWorld]:11 - this is info:sdibt
2018-05-10 10:46:29,566 DEBUG [example.HelloWorld]:12 - this is debug:sdibt
List<String> 和 Set<String> 可以直接打印, 但List<User> 需要重写User的equals和hashcode方法才可以打印
List<String> list = new ArrayList<>();
list.add("1");
list.add("1" );
log.info("list集合: {}", list); // 结果是 [1, 1]
Set<String> set = new HashSet<>();
set.add("1");
set.add("1" );
log.info("set集合: {}", set); // 结果是 [1]
边栏推荐
- Several common errors when using MP
- BUG definition of SonarQube
- 刚出道“一战成名”,安全、舒适一个不落
- 【C语言】求两个整数m和n的最大公因数和最小公倍数之和一般方法,经典解法
- MultipartFile file upload
- CorelDRAW2022 streamlined Asia Pacific new features in detail
- [Android] Room - Alternative to SQLite
- [Godot][GDScript] 2D cave map randomly generated
- els block to the right
- 观察者模式
猜你喜欢
华为分布式存储FusionStorage知识点总结【面试篇】
Use of QML
Detailed explanation of TCP (3)
6. Display comments and replies
【C语言】进制转换一般方法
12 Disk related commands
Several common errors when using MP
【Exception】The field file exceeds its maximum permitted size of 1048576 bytes.
LeetCode简单题之两个数组间的距离值
Mysql 45讲学习笔记(二十三)MYSQL怎么保证数据不丢
随机推荐
Day32 LeetCode
递归查询单表-单表树结构-(自用)
STM32问题合集
Getting Started with CefSharp - winform
CefSharp入门-winform
测试中的误报和漏报同样的值得反复修正
10. Redis implements likes (Set) and obtains the total number of likes
els 方块向左移动条件判断
LeetCode每日一练 —— OR36 链表的回文结构
VS QT——ui不显示新添加成员(控件)||代码无提示
顺序表的实现
SocialFi 何以成就 Web3 去中心化社交未来
Key Technologies of Interface Testing
注解用法含义
想从手工测试转岗自动化测试,需要学习哪些技能?
els block to the right
return in try-catch
数据库实现分布式锁
The els block moves the boundary to the right, and accelerates downward.
YOLOV5 study notes (2) - environment installation + operation + training