473,388 Members | 1,207 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Enterprise Library Logging Application Block

Hi,

Using the EnterpriseLibrary 4.0, is it possible to Log the method
name in the log file.

I have it cofigured thus:
<loggingConfiguration name="Logging Application Block"
tracingEnabled="true"
defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<listeners>
<add fileName="trace.log"
header="----------------------------------------"
footer="----------------------------------------" formatter=""

listenerDataType="Microsoft.Practices.EnterpriseLi brary.Logging.Configuration.FlatFileTraceListenerD ata,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
traceOutputOptions="Timestamp" filter="All"
type="Microsoft.Practices.EnterpriseLibrary.Loggin g.TraceListeners.FlatFileTraceListener,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="FlatFile TraceListener" />
</listeners>
<formatters>
<add template="Timestamp: {timestamp}&#xD;&#xA;Message:
{message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority:
{priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity:
{severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Method:
{method}&#xD;&#xA;Machine: {machine}&#xD;&#xA;Application Domain:
{appDomain}&#xD;&#xA;Process Id: {processId}&#xD;&#xA;Process Name:
{processName}&#xD;&#xA;Win32 Thread Id:
{win32ThreadId}&#xD;&#xA;Thread Name: {threadName}&#xD;&#xA;Extended
Properties: {dictionary({key} - {value}&#xD;&#xA;)}"

type="Microsoft.Practices.EnterpriseLibrary.Loggin g.Formatters.TextFormatter,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
name="Text Formatter" />
</formatters>
<categorySources>
<add switchValue="All" name="General">
<listeners>
<add name="FlatFile TraceListener" />
</listeners>
</add>
</categorySources>
<specialSources>
<allEvents switchValue="All" name="All Events" />
<notProcessed switchValue="All" name="Unprocessed Category" />
<errors switchValue="All" name="Logging Errors &amp; Warnings">
<listeners>
<add name="FlatFile TraceListener" />
</listeners>
</errors>
</specialSources>
</loggingConfiguration>

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<Customer,
IDomainEntity>("Arun", null);
string res = customer.Validate();

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\PIABTest\PIABTest\bin\Debug
\PIABTest.vshost.exe
Thread Name:
Win32 ThreadId:16656
Extended Properties:
Timestamp=12107455156919
----------------------------------------
----------------------------------------
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\PIABTest\PIABTest\bin\Debug
\PIABTest.vshost.exe
Thread Name:
Win32 ThreadId:16656
Extended Properties:
Timestamp=12107458102597
----------------------------------------

How do I include the method name too in each log entry?

thanks,

Arun
Oct 3 '08 #1
1 2592
I'm not sure if there is a kewyord for the method name to put in the
configuration, but I use Extended property in Exception handler and
that works fine see below...

catch (Exception ex)
{
SetMasterPageProperty(AppConstants.ErrorMessage,
ex.Message);
ex.Data.Add("Method Name: ", "btnInsert_Click()");
Boolean rethrow;
rethrow = ExceptionPolicy.HandleException(ex,
AppConstants.UIPolicy);
}

Oct 3 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ahsan | last post by:
Exception Application Block creates a Exception GUID that gets saved in the sink e.g. application log. How do I show this to a user on the web, so the user can use it as a reference when calling...
1
by: Ollie Riches | last post by:
I have written a custom logging sink for the enterprise library logging application block (June 2005). I have been able to configure it as expected from the UI config tool (EntLibConfig.exe). I...
1
by: Ollie Riches | last post by:
I am trying to use asynchronous logging using MSMQ and I have configured the properties as defined in the help (see below) I don't understand where the property 'MsmqPath' is in the app.config for...
7
by: amitos | last post by:
Hi! I consider using the Logging Application Block, Enterprise Library, Jan 2006 in a major project. To date, I've found that some of its features are not very well documented. One important...
3
by: Dick | last post by:
How do I integrating ASP.NET Tracing with the Enterprise Library Logging Application Block? I guess this should be possible and in a similar way to the way ASP.NET Tracing is integrated with...
1
by: sreedharv | last post by:
Log4Net vs Enterprise Library - Logging Application Block Please list or point to the comparison. My requirements are: - 50 to 70 web servers - Track Machine name - Extract class / method...
2
by: Anup Daware | last post by:
Hi Group, Can somebody tell me where I can find the internals of Logging application block 2.0/3.0. I need answers for the questions like: What best practices have followed in the...
0
by: =?Utf-8?B?d2lsbGlhbQ==?= | last post by:
Hi, I want to cache some stable user information on client side for later use by VB clients, so I implement enterprise library cache application block in COM+ serviced component which is...
0
by: adeelansari | last post by:
Any one can send me the code sample of Cache Application Block of Enterprise Library using Database storage , i successfully used the NullBackingStore , Please send me some sort of idea or code so...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.