Encrypting data on Logging Application Block

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
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:
<pre class="prettyprint 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);[/code]
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:
<pre class="prettyprint <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>[/code]
<br/>
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 <hr class="sig meeram395

View the full article
 
Back
Top