Problem In Logging to The rolling Flat file Listener for Microsoft Enterprise Library

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi Experts,
I am have an issue with the Enterprise Library Logging which I am developing as a [part of my Customised shopping cart Application. The issue I face is That I always getting this nagging error
The file e:BuildsEntLibLatestSourceBlocksLoggingSrcLoggingLogWriterImpl.cs does not exist.
I am unable to fix this.
The config file I have is:-
<configuration><br/>
<configSections><br/>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
requirePermission="true" /><br/>
</configSections><br/>
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General <br/>
<listeners><br/>
<add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"<br/>
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"<br/>
source="Enterprise Library Logging" formatter="Text Formatter"<br/>
log="BlackBox" machineName="." traceOutputOptions="None" /><br/>
<add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"<br/>
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"<br/>
fileName="F:EntLoggingCartLogging.log" formatter="Text Formatter"<br/>
rollSizeKB="20" maxArchivedFiles="20" traceOutputOptions="DateTime, Timestamp, ProcessId, ThreadId, Callstack" /><br/>
</listeners><br/>
<formatters><br/>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"<br/>
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})}"<br/>
name="Text Formatter" /><br/>
</formatters><br/>
<categorySources><br/>
<add switchValue="All" name="General <br/>
<listeners><br/>
<add name="Event Log Listener" /><br/>
</listeners><br/>
</add><br/>
</categorySources><br/>
<specialSources><br/>
<allEvents switchValue="All" name="All Events" /><br/>
<notProcessed switchValue="All" name="Unprocessed Category" /><br/>
<errors switchValue="All" name="Logging Errors &amp; Warnings <br/>
<listeners><br/>
<add name="Event Log Listener" /><br/>
</listeners><br/>
</errors><br/>
</specialSources><br/>
</loggingConfiguration><br/>
</configuration><br/>

My code for Logging is as follows:-
using System;<br/>
using System.Collections.Generic;<br/>
using System.Linq;<br/>
using System.Text;<br/>
using System.Web;<br/>
using Microsoft.Practices.EnterpriseLibrary.Common;<br/>
using Microsoft.Practices.EnterpriseLibrary.Logging;<br/>
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;<br/>
namespace CartLibrary<br/>
{<br/>
public static class CartLogger<br/>
{<br/>
static LogWriter writer = null;<br/>
static CartLogger()<br/>
{<br/>
FileConfigurationSource fcs = new FileConfigurationSource(@"C:Logica.ConfigLogica.Intranet.EnterpriseLibrary.config");<br/>
LogWriterFactory factory = new LogWriterFactory(fcs);<br/>
writer = factory.CreateDefault();<br/>
}<br/>
<br/>
<br/>
<br/>
public static void LogError(string message, Exception ex)<br/>
{<br/>
LogError(ApplicationType.None, message, ex, Priority.High);<br/>
}<br/>
<br/>
public static void LogError(ApplicationType module,string message, Exception ex)<br/>
{<br/>
LogError(module, message, ex, Priority.High);<br/>
}<br/>
<br/>
public static void LogError(ApplicationType module, string message, Exception ex, Priority priority)<br/>
{<br/>
LogEntry e = new LogEntry();<br/>
e.Severity = System.Diagnostics.TraceEventType.Error;<br/>
StringBuilder sb = new StringBuilder();<br/>
sb.Append(message);<br/>
sb.Append(Environment.NewLine);<br/>
sb.Append(ex.Message);<br/>
sb.Append(Environment.NewLine);<br/>
sb.Append(ex.StackTrace);<br/>
sb.Append(Environment.NewLine);<br/>
sb.Append(OtherInformations());<br/>
e.Message = sb.ToString();<br/>
e.Priority = (int)priority;<br/>
e.Title = module.ToString("g");<br/>
writer.Write(e);<br/>
}<br/>
<br/>
public static void LogInfo(ApplicationType module, string message)<br/>
{<br/>
LogInfo(module, message, Priority.Low);<br/>
}<br/>
<br/>
public static void LogInfo(string message)<br/>
{<br/>
LogInfo(ApplicationType.None, message, Priority.Low);<br/>
}<br/>
<br/>
public static void LogInfo(ApplicationType module, string message, Priority priority)<br/>
{<br/>
LogEntry e = new LogEntry();<br/>
e.Severity = System.Diagnostics.TraceEventType.Information;<br/>
e.Message = message;<br/>
e.Priority = (int)priority;<br/>
e.Title = module.ToString("g");<br/>
writer.Write(e);<br/>
}<br/>
private static string OtherInformations()<br/>
{<br/>
StringBuilder sb = new StringBuilder();<br/>
if (HttpContext.Current!=null)<br/>
{<br/>
sb.Append("Url:");<br/>
sb.Append(HttpContext.Current.Request.Url.ToString());<br/>
<br/>
if (HttpContext.Current.Request.LogonUserIdentity!=null)<br/>
{<br/>
sb.Append(Environment.NewLine);<br/>
sb.Append("User:");<br/>
sb.Append(HttpContext.Current.Request.LogonUserIdentity.Name);<br/>
}<br/>
}<br/>
return sb.ToString();<br/>
}<br/>
}<br/>
}<br/>

Where I am doing wrong??am i missing any config sections??
Please help me out Experts.

Thanks and Regards,
Nilanjan

View the full article
 
Back
Top