EDN Admin
Well-known member
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}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Title:{title}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
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
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}
Message: {message}{newline}
Category: {category}{newline}
Priority: {priority}{newline}
EventId: {eventid}{newline}
Severity: {severity}{newline}
Title:{title}{newline}
Machine: {localMachine}{newline}
App Domain: {localAppDomain}{newline}
ProcessId: {localProcessId}{newline}
Process Name: {localProcessName}{newline}
Thread Name: {threadName}{newline}
Win32 ThreadId:{win32ThreadId}{newline}
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