当前位置:网站首页>日志级别 和 打印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]边栏推荐
- 大小端模式
- JS function this context runtime syntax parentheses array IIFE timer delay self.backup context call apply
- C# remote debugging
- 8. Unified exception handling (controller notifies @ControllerAdvice global configuration class, @ExceptionHandler handles exceptions uniformly)
- LeetCode简单题之两个数组间的距离值
- SQL injection Less46 (injection after order by + rand() Boolean blind injection)
- LeetCode中等题之分数加减运算
- Getting Started with CefSharp - winform
- web容器及IIS --- 中间件渗透方法1
- The els block moves the boundary to the right, and accelerates downward.
猜你喜欢

递归查询单表-单表树结构-(自用)

接口测试关键技术

The simulation application of common mode inductance is here, full of dry goods for everyone

VS QT——ui不显示新添加成员(控件)||代码无提示

10. Redis implements likes (Set) and obtains the total number of likes

Software accumulation -- Screenshot software ScreenToGif

Moxa NPort 设备缺陷可能使关键基础设施遭受破坏性攻击

How to develop a high-quality test case?

STM32 problem collection

TCP和UDP详解
随机推荐
some of my own thoughts
Software accumulation -- Screenshot software ScreenToGif
How to develop a high-quality test case?
【异常】The field file exceeds its maximum permitted size of 1048576 bytes.
测试中的误报和漏报同样的值得反复修正
Modbus on AT32 MCUs
LeetCode每日一练 —— 138. 复制带随机指针的链表
Unity3D Button mouse hover enter and mouse hover exit button events
What is distributed and clustered?What is the difference?
观察者模式
【C语言】进制转换一般方法
【编译原理】词法分析程序设计原理与实现
Moxa NPort 设备缺陷可能使关键基础设施遭受破坏性攻击
Redis implements distributed locks
[Compilation principle] Lexical analysis program design principle and implementation
IDEA 注释报红解决
接口测试关键技术
Several common errors when using MP
Chapter 9 SVM实践
CefSharp入门-winform