locked
Encrypting data on Logging Application Block RRS feed

  • Question

  • I have a requirememnt to encrypt the messages generated by the logging applicationblock. I am using flat file trace listener and even file trace listener.  I am encrypting the message now using the Cryptography application block by using the following code:

    using Microsoft.Practices.EnterpriseLibrary.Logging;
    using Microsoft.Practices.EnterpriseLibrary.Security.Cryptography;
    
     LogEntry logEntry = new LogEntry();
     logEntry.Message = Cryptographer.CreateHash("SHA1", "Starting the application");
    Logger.Write(logEntry);

    My question is, is this the proper way or is there any other method which we can encrypt the data? Also, I need to encrypt the automatic properties which are logged in the file. For eg. in the web.config file, we declare as below:

     <formatters>
                <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
                    template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}"
                    name="Text Formatter" />
            </formatters>

    Now, I need to encrypt the values of the properties which are coming inside the template attribute. Is there any way? Please help.

    Thanks,

    meeram395


    meeram395

    Monday, November 5, 2012 10:50 AM

Answers

All replies