gpt4 book ai didi

log4j - log4j 中使用的格式字符是什么并解释它们的用法并给我一些例子?

转载 作者:行者123 更新时间:2023-12-04 04:41:12 25 4
gpt4 key购买 nike

我在 log4j 配置 xml 中有以下条目。 '%p'、'%C;%L'、'%m' 的意义是什么。这些字符代表什么?还有哪些字符,我们可以在 log4j 中使用?解释它们的用法..

<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="INSERT INTO LOGS (user_id, dated, msg_level, class, message)
VALUES ( '%X{MESSAGE_ID}','%d{ISO8601}','%p', '%C;%L', '%m' )" />
</layout>

最佳答案

一些主要的转换字符是

p --- Used to output the priority of the logging event.

C --- Used to output the fully qualified class name of the caller issuing the logging request.

L --- Used to output the line number from where the logging request was issued.

m --- Used to output the application supplied message associated with the logging event.



使用带有任何转换字符的数字,例如 %4p意味着

the priority of the logging event should be left justified to a width of four characters.



除了这种转换,还有其他模式。
您可以查看有关它们的详细信息 here .

关于log4j - log4j 中使用的格式字符是什么并解释它们的用法并给我一些例子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18872506/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com