问题
I recently created my simple log4net database table for logging via the adonet appender.. and it works !
But then i notice another website using additional fields! Look!
Wow! i would love to know where i can get a list of available field names, for example Method_name really gets me thinking!!!
But logging normally supports adding to this field or do i need a wrapper or something?? i see via the log4net config it has the method_name point to the database field and has this
"<conversionPattern value="%property{method_name}"/>"
which is great but how do i populate this before calling the logger?
I was using a standard Thread, logger, message and exception FIELD NAMES ....
Anybody have a recommendation or experience in what esle i can log ... I would be great to be able to the log the method name, i am using the "LOGGER" field from GetType which gives me namespace and class...
回答1:
Here's a list of all the different values you can put into a conversion pattern.
Sounds like what you want is to use %method pattern:
<conversionPattern value="%method" />
You can also create custom properties and push them into the log4net context.
log4net.ThreadContext.Properties["custom"] = "Custom Value";
<conversionPattern value="%property{custom}" />
来源:https://stackoverflow.com/questions/1324604/log4net-available-database-fields-for-adoappender-seems-there-are-a-few-more-i