MS Enterprise Logging 5.0 : Issue with Formatter and Category Restrictions.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Frnds,
Im using MS Enterprise Logging 5.0, my template is not working as expected and im unable to restirct category as "error" to be written in my Logs..
below is my config file
<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"<br/>
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"<br/>
source="Enterprise Library Logging" formatter="Text Formatter"<br/>
log="" machineName="." traceOutputOptions="None"/><br/>
<add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"<br/>
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"<br/>
footer="---------------------------------------------" formatter="Trace Formatter"<br/>
header="&quot;######################################&quot;"<br/>
rollFileExistsBehavior="Increment" rollInterval="Day" rollSizeKB="1024"<br/>
traceOutputOptions="None" fileName="C:LogsSampleLog.txt"/><br/>
</listeners><br/>
<formatters><br/>
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"<br/>
template="{timestamp(local)}: {message}"<br/>
name="Trace Formatter" /><br/>
</formatters><br/>
<categorySources><br/>
<add switchValue="All" name="General <br/>
<listeners><br/>
<add name="Rolling Flat File Trace 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="Error" name="Logging Errors &amp; Category <br/>
<listeners><br/>
<add name="Rolling Flat File Trace Listener" /><br/>
</listeners><br/>
</errors><br/>
</specialSources><br/>
</loggingConfiguration>
<br/>
these are the errors logged :: <br/>
---------------------------------------------<br/>
"######################################"<br/>
7/3/2012 9:01:00 PM: There is no explicit mapping for the categories Error. The log entry was:
<br/>
Timestamp: 7/3/2012 9:00:59 PM<br/>
Message: System.NullReferenceException: Object reference not set to an instance of an object.<br/>
at Cig.Ums.Epas.Service.ServiceImplementation.PolicyService.RetrieveClaimsSummaryInfo(String policyId) in D:ProjectSourceCode-TFSCIG.UMS.ePAS.Service.ServiceImplementationPolicyService.cs:line 3515<br/>
Category: Error<br/>
Priority: -1<br/>
EventId: 100<br/>
Severity: Information<br/>
Title:RetrieveClaimsSummaryInfo<br/>
Machine: Texas<br/>
App Domain: TestAppDomain: 93b143fc-3247-42cd-b72c-bf1da801027b<br/>
ProcessId: 6420<br/>
Process Name: C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEQTAgent32.exe<br/>
Thread Name: Agent: adapter run thread for test RetrieveClaimsSummaryInfoTest with id b0ca4013-d21b-49c9-87de-1ce1ca0ac5ec<br/>
Win32 ThreadId:11104<br/>
Extended Properties: <br/>
---------------------------------------------<br/>
"######################################"<br/>
7/3/2012 9:01:00 PM: There is no explicit mapping for the categories Trace. The log entry was:
<br/>
Timestamp: 7/3/2012 9:01:00 PM<br/>
Message: System.NullReferenceException: Object reference not set to an instance of an object.<br/>
at Cig.Ums.Epas.Service.ServiceImplementation.PolicyService.RetrieveClaimsSummaryInfo(String policyId) in D:ProjectSourceCode-TFSCIG.UMS.ePAS.Service.ServiceImplementationPolicyService.cs:line 3515<br/>
Category: Trace<br/>
Priority: 5<br/>
EventId: 100<br/>
Severity: Verbose<br/>
Title:RetrieveClaimsSummaryInfo<br/>
Machine: Texas<br/>
App Domain: TestAppDomain: 93b143fc-3247-42cd-b72c-bf1da801027b<br/>
ProcessId: 6420<br/>
Process Name: C:Program Files (x86)Microsoft Visual Studio 10.0Common7IDEQTAgent32.exe<br/>
Thread Name: Agent: adapter run thread for test RetrieveClaimsSummaryInfoTest with id b0ca4013-d21b-49c9-87de-1ce1ca0ac5ec<br/>
Win32 ThreadId:11104<br/>
Extended Properties: <br/>
---------------------------------------------

I want to restrict only Category as "Error" to be written in logs and template is not working as per my requirement !
methods ::
public static void WriteException(string title, string message, int eventId)<br/>
{<br/>
LogEntry logEntry = new LogEntry();<br/>
logEntry.Title = title;<br/>
logEntry.Message = message;<br/>
logEntry.EventId = eventId;<br/>
logEntry.TimeStamp = DateTime.Now;<br/>
logEntry.Categories.Add(Category.Error.ToString());
Write(logEntry);<br/>
}
<br/>
public static void Write(LogEntry logEntry)<br/>
{<br/>
Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Writer.Write(logEntry);<br/>
}
please help me in this !
<br/>

View the full article
 
Back
Top