当前位置:网站首页>日志级别 和 打印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]边栏推荐
- Software accumulation -- Screenshot software ScreenToGif
- Annotation usage meaning
- 【C语言】求两个整数m和n的最大公因数和最小公倍数之和一般方法,经典解法
- LeetCode简单题之两个数组间的距离值
- 华为分布式存储FusionStorage知识点总结【面试篇】
- IDEA 注释报红解决
- PMP WeChat group daily exercises
- With 7 years of experience, how can functional test engineers improve their abilities step by step?
- Mysql 45讲学习笔记(二十五)MYSQL保证高可用
- 【Exception】The field file exceeds its maximum permitted size of 1048576 bytes.
猜你喜欢

Mysql 45讲学习笔记(二十三)MYSQL怎么保证数据不丢

Multilingual settings of php website (IP address distinguishes domestic and foreign)

Crypto Firms Offer Offer To Theft Hackers: Keep A Little, Give The Rest

什么是分布式锁?实现分布式锁的三种方式

想从手工测试转岗自动化测试,需要学习哪些技能?

Problems that need to be solved in distributed system architecture

C#远程调试

6. Display comments and replies

Ambiguous method call.both

分布式系统架构需要解决的问题
随机推荐
【C语言】三子棋(经典解法+一览图)
Several common errors when using MP
PMP微信群日常习题
7年经验,功能测试工程师该如何一步步提升自己的能力呢?
品牌广告投放平台的中台化应用与实践
选好冒烟测试用例,为进入QA的制品包把好第一道关
IDEA 注释报红解决
Project (5) - Small target detection tph-yolov5
Observer pattern
Number 16, top posts
华为分布式存储FusionStorage知识点总结【面试篇】
Recursive query single table - single table tree structure - (self-use)
BUG definition of SonarQube
4. Sensitive word filtering (prefix tree)
The els block moves the boundary to the right, and accelerates downward.
endian mode
Modbus on AT32 MCUs
How to develop a high-quality test case?
SQALE 是什么
[C language foundation] Solve C language error: expected ';', ',' or ')' before '&' token