能否在log4net %属性中设置字符限制为10个字符?
Can we set the characters limited to 10 characters in log4net %property?
这是我的 threadContext 异常消息 属性
log4net.ThreadContext.Properties["excmessage"] = ex.Message;
我想使用 log4net 获取异常消息 属性 的前 10 个字符。
这是 Log4net.config 中的行:
%property{excmessage}
据我所知,你只能 "truncate from the beginning" 这意味着你得到了字符串的结尾:
%.10property{excmessage}
这是文档的 link:
http://logging.apache.org/log4net/log4net-1.2.11/release/sdk/log4net.Layout.PatternLayout.html
我建议您填写两个属性:一个是异常消息,另一个是截断消息。
这是我的 threadContext 异常消息 属性
log4net.ThreadContext.Properties["excmessage"] = ex.Message;
我想使用 log4net 获取异常消息 属性 的前 10 个字符。
这是 Log4net.config 中的行:
%property{excmessage}
据我所知,你只能 "truncate from the beginning" 这意味着你得到了字符串的结尾:
%.10property{excmessage}
这是文档的 link: http://logging.apache.org/log4net/log4net-1.2.11/release/sdk/log4net.Layout.PatternLayout.html
我建议您填写两个属性:一个是异常消息,另一个是截断消息。