Hi,
Using the EnterpriseLibra ry 4.0, is it possible to Log the method
name in the log file.
I have it cofigured thus:
<loggingConfigu ration name="Logging Application Block"
tracingEnabled= "true"
defaultCategory ="General" logWarningsWhen NoCategoriesMat ch="true">
<listeners>
<add fileName="trace .log"
header="----------------------------------------"
footer="----------------------------------------" formatter=""
listenerDataTyp e="Microsoft.Pr actices.Enterpr iseLibrary.Logg ing.Configurati on.FlatFileTrac eListenerData,
Microsoft.Pract ices.Enterprise Library.Logging , Version=4.0.0.0 ,
Culture=neutral , PublicKeyToken= 31bf3856ad364e3 5"
traceOutputOpti ons="Timestamp" filter="All"
type="Microsoft .Practices.Ente rpriseLibrary.L ogging.TraceLis teners.FlatFile TraceListener,
Microsoft.Pract ices.Enterprise Library.Logging , Version=4.0.0.0 ,
Culture=neutral , PublicKeyToken= 31bf3856ad364e3 5"
name="FlatFile TraceListener" />
</listeners>
<formatters>
<add template="Times tamp: {timestamp}
 ;
Message :
{message}
& #xA;Category: {category}
 
Priorit y:
{priority}
 
EventId : {eventid}
& #xA;Severity:
{severity}
 
Title:{tit le}
Me thod:
{method}
&# xA;Machine: {machine}
& #xA;Application Domain:
{appDomain}
 ;
Process Id: {processId}
 ;
Process Name:
{processName}&# xD;
Win32 Thread Id:
{win32ThreadId} 
Threa d Name: {threadName}&#x D;
Extende d
Properties: {dictionary({ke y} - {value}
&#x A;)}"
type="Microsoft .Practices.Ente rpriseLibrary.L ogging.Formatte rs.TextFormatte r,
Microsoft.Pract ices.Enterprise Library.Logging , Version=4.0.0.0 ,
Culture=neutral , PublicKeyToken= 31bf3856ad364e3 5"
name="Text Formatter" />
</formatters>
<categorySource s>
<add switchValue="Al l" name="General">
<listeners>
<add name="FlatFile TraceListener" />
</listeners>
</add>
</categorySources >
<specialSources >
<allEvents switchValue="Al l" name="All Events" />
<notProcessed switchValue="Al l" name="Unprocess ed Category" />
<errors switchValue="Al l" name="Logging Errors & Warnings">
<listeners>
<add name="FlatFile TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfigur ation>
My Interface ios configured thus:
public interface IDomainEntity
{
[Tag("Log")]
string Validate();
}
I am using the Policy Injection App Block thus
IDomainEntity customer = PolicyInjection .Create<Custome r,
IDomainEntity>( "Arun", null);
string res = customer.Valida te();
I want to log the method name too (in his case Validate()) to the log
file. Currently my app spits out the following log file:
----------------------------------------
General Information: 0 : Timestamp: 10/3/2008 9:53:57 AM
Message:
Category: General
Priority: -1
EventId: 0
Severity: Information
Title:Call Logging
Machine: PSI-2503-ARUN
App Domain: PIABTest.vshost .exe
ProcessId: 60620
Process Name: E:\MyProjects\P IABTest\PIABTes t\bin\Debug
\PIABTest.vshos t.exe
Thread Name:
Win32 ThreadId:16656
Extended Properties:
Timestamp=12107 455156919
----------------------------------------
----------------------------------------
General Information: 0 : Timestamp: 10/3/2008 9:53:58 AM
Message:
Category: General
Priority: -1
EventId: 0
Severity: Information
Title:Call Logging
Machine: PSI-2503-ARUN
App Domain: PIABTest.vshost .exe
ProcessId: 60620
Process Name: E:\MyProjects\P IABTest\PIABTes t\bin\Debug
\PIABTest.vshos t.exe
Thread Name:
Win32 ThreadId:16656
Extended Properties:
Timestamp=12107 458102597
----------------------------------------
How do I include the method name too in each log entry?
thanks,
Arun
Using the EnterpriseLibra ry 4.0, is it possible to Log the method
name in the log file.
I have it cofigured thus:
<loggingConfigu ration name="Logging Application Block"
tracingEnabled= "true"
defaultCategory ="General" logWarningsWhen NoCategoriesMat ch="true">
<listeners>
<add fileName="trace .log"
header="----------------------------------------"
footer="----------------------------------------" formatter=""
listenerDataTyp e="Microsoft.Pr actices.Enterpr iseLibrary.Logg ing.Configurati on.FlatFileTrac eListenerData,
Microsoft.Pract ices.Enterprise Library.Logging , Version=4.0.0.0 ,
Culture=neutral , PublicKeyToken= 31bf3856ad364e3 5"
traceOutputOpti ons="Timestamp" filter="All"
type="Microsoft .Practices.Ente rpriseLibrary.L ogging.TraceLis teners.FlatFile TraceListener,
Microsoft.Pract ices.Enterprise Library.Logging , Version=4.0.0.0 ,
Culture=neutral , PublicKeyToken= 31bf3856ad364e3 5"
name="FlatFile TraceListener" />
</listeners>
<formatters>
<add template="Times tamp: {timestamp}
 ;
Message :
{message}
& #xA;Category: {category}
 
Priorit y:
{priority}
 
EventId : {eventid}
& #xA;Severity:
{severity}
 
Title:{tit le}
Me thod:
{method}
&# xA;Machine: {machine}
& #xA;Application Domain:
{appDomain}
 ;
Process Id: {processId}
 ;
Process Name:
{processName}&# xD;
Win32 Thread Id:
{win32ThreadId} 
Threa d Name: {threadName}&#x D;
Extende d
Properties: {dictionary({ke y} - {value}
&#x A;)}"
type="Microsoft .Practices.Ente rpriseLibrary.L ogging.Formatte rs.TextFormatte r,
Microsoft.Pract ices.Enterprise Library.Logging , Version=4.0.0.0 ,
Culture=neutral , PublicKeyToken= 31bf3856ad364e3 5"
name="Text Formatter" />
</formatters>
<categorySource s>
<add switchValue="Al l" name="General">
<listeners>
<add name="FlatFile TraceListener" />
</listeners>
</add>
</categorySources >
<specialSources >
<allEvents switchValue="Al l" name="All Events" />
<notProcessed switchValue="Al l" name="Unprocess ed Category" />
<errors switchValue="Al l" name="Logging Errors & Warnings">
<listeners>
<add name="FlatFile TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfigur ation>
My Interface ios configured thus:
public interface IDomainEntity
{
[Tag("Log")]
string Validate();
}
I am using the Policy Injection App Block thus
IDomainEntity customer = PolicyInjection .Create<Custome r,
IDomainEntity>( "Arun", null);
string res = customer.Valida te();
I want to log the method name too (in his case Validate()) to the log
file. Currently my app spits out the following log file:
----------------------------------------
General Information: 0 : Timestamp: 10/3/2008 9:53:57 AM
Message:
Category: General
Priority: -1
EventId: 0
Severity: Information
Title:Call Logging
Machine: PSI-2503-ARUN
App Domain: PIABTest.vshost .exe
ProcessId: 60620
Process Name: E:\MyProjects\P IABTest\PIABTes t\bin\Debug
\PIABTest.vshos t.exe
Thread Name:
Win32 ThreadId:16656
Extended Properties:
Timestamp=12107 455156919
----------------------------------------
----------------------------------------
General Information: 0 : Timestamp: 10/3/2008 9:53:58 AM
Message:
Category: General
Priority: -1
EventId: 0
Severity: Information
Title:Call Logging
Machine: PSI-2503-ARUN
App Domain: PIABTest.vshost .exe
ProcessId: 60620
Process Name: E:\MyProjects\P IABTest\PIABTes t\bin\Debug
\PIABTest.vshos t.exe
Thread Name:
Win32 ThreadId:16656
Extended Properties:
Timestamp=12107 458102597
----------------------------------------
How do I include the method name too in each log entry?
thanks,
Arun
Comment