gpt4 book ai didi

Log4net - 在控制台中显示时间(不是日期)

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

我正在使用 log4net 登录到控制台,并且 %date conversionPattern 值太冗长。
我只想看到 hh:mm:ss - 不需要日期,因为我知道今天的日期。

当前配置:

[conversionPattern value="%date %-5level - %message%newline"/]

最佳答案

您可以使用 dateutcdate根据您的规范格式化日期:

date

Used to output the date of the logging event in the local time zone. To output the date in universal time use the %utcdate pattern. The date conversion specifier may be followed by a date format specifier enclosed between braces. For example, %date{HH:mm:ss,fff} or %date{dd MMM yyyy HH:mm:ss,fff}. If no date format specifier is given then ISO8601 format is assumed (Iso8601DateFormatter).

The date format specifier admits the same syntax as the time pattern string of the ToString.

For better results it is recommended to use the log4net date formatters. These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying AbsoluteTimeDateFormatter, DateTimeDateFormatter and respectively Iso8601DateFormatter. For example, %date{ISO8601} or %date{ABSOLUTE}.

These dedicated date formatters perform significantly better than ToString.

utcdate

Used to output the date of the logging event in universal time. The date conversion specifier may be followed by a date format specifier enclosed between braces. For example, %utcdate{HH:mm:ss,fff} or %utcdate{dd MMM yyyy HH:mm:ss,fff}. If no date format specifier is given then ISO8601 format is assumed (Iso8601DateFormatter).

The date format specifier admits the same syntax as the time pattern string of the ToString.

For better results it is recommended to use the log4net date formatters. These can be specified using one of the strings "ABSOLUTE", "DATE" and "ISO8601" for specifying AbsoluteTimeDateFormatter, DateTimeDateFormatter and respectively Iso8601DateFormatter. For example, %utcdate{ISO8601} or %utcdate{ABSOLUTE}.

These dedicated date formatters perform significantly better than ToString.



来源: log4net PatternLayout documentation .

关于Log4net - 在控制台中显示时间(不是日期),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1338504/

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