c# - How do I configure log4net such that properties of an object can be mapped to the log output? -


By offering a SOAP web service, trying to provide an instrument for logging errors in our Flex client I am having a single parameter which is a log message object

  public class log message {public string message {get; Set; } Public string exception {get; Set; } Public string version {get; Set; } Public string user {get; Set; }}  

This object is populated by the Flex client, the client side should be the error surface and log client error is applied, which logs the error via log 4 net. Webmaster (Webmaster): Public Zero Log Client Error (Log Message Message) {rollinglogger.Error (Message); }

At present, this prints a fully qualified name of the log message class, so my current assumption is that the log4net bus just calls. Toasting on the object that has been passed from inside.

However, what I really want to be able to do, map every property in a pattern in the log message class so that log4net can write the desired information correctly. I would like to do this in a way that the typical appenders (DB, File, SMTP) are all still supported.

How can I configure log4net, like the properties of an object can be mapped to the logging output?

The log4 net has two routes that you can take to create a custom object renderer for the first LogMessage instances . You need to implement

The other way, which will be more reusable, the patterned layout class is for the sub-class. Your custom pattern layout can then support special syntax for naming the attributes, which are the layout on the incoming message object Can be used to reflect.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -