问题
This is my threadContext exception message property
log4net.ThreadContext.Properties["excmessage"] = ex.Message;
I want to get the first 10 characters of exception message property using log4net.
This is the line in Log4net.config:
%property{excmessage}
回答1:
As far as I can tell you can only "truncate from the beginning" which means you get the end of the string:
%.10property{excmessage}
Here is a link to the documentation: http://logging.apache.org/log4net/log4net-1.2.11/release/sdk/log4net.Layout.PatternLayout.html
I suggest that you fill two properties: one with the exception message and the other with the truncated message.
来源:https://stackoverflow.com/questions/50228371/can-we-set-the-characters-limited-to-10-characters-in-log4net-property