Enterprise Library 5.0 Logging Application Block: Log Custome Message using a DatabaseTraceListener -


I am using Enterprise Library 5.0 and my job is to log in to the database. For this, I used the Enterprise Library logging application block with the database trace listener.

Now, after a few days I came to know that I need some more information to log in to logging. They are: User_ID, session_ID etc.

per occupational requirements, I can not use the expanded property of the login category and store this information in the XML table in the formatted message column of the logs table. I need the proper column with the name "User_ID" and "session_ID" in the logs table of the logging database.

The question is: How can I push the information customized into the log in table?

For this, I found something called "custom tracelestor", where we need to override two methods, such as write (string message) & amp; WriteLog (String Message)

  • How do I use this CustomeTraceListener to push the customs message for the lock table?

  • Write method takes a single type of paragraph string means that I will get a given string, which is to break into different information and use my own code Do you have to push into the database?

    Can anyone send me the implimentation example of CustomeTraceListener - & gt;

    Thanks,

    Sun

    = "Text">

    To create a custom trace listener, follow this:

    You can use Fluent Configuration (code not working, but gives an idea) again in this way:

      var Builder = new configurationSourceBuilder (); Var serviceConfig = New Name ValueCollection (); ServiceConfig.Add ("Key", "Data"); Builder. Configure logging () .Logtracredited ("normal"). Actions. Ctesace Default Caribbean () .SendTo.Custom & lt; ServiceTraceListener & gt; ("ServiceTraceListener", serviceConfig) .with format (new form builder (.) TextFormatterNamed ("Text Formatter"). Use the template "Timestamp: {Timestamp} ... {Newline}}"));); Var configSource = new dictionary source (); ConfigSource.Add (Logging Settings. Sanketnam, Builder .gate (Logging Settings .netname)); Var cont = EnterpriseLibraryContainer.CreateDefaultContainer (configSource); Return cont.GetInstance & lt; LogWriter & gt; ();   

    (± by code)

    Here is an overview of the data that you can use in the .UsingTemplate method :

    This template is being used in your custom trace listener tracedata override method (if you follow Walkthrough connected to MSDN I here).

    See also: Extra formatting:

Comments