473,406 Members | 2,404 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,406 software developers and data experts.

Logging Application Block vs. System.Web.TraceContext

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 System.Diagnostics Tracing as described in
http://msdn2.microsoft.com/en-us/lib...xd(VS.80).aspx. But I would
have thought this is something most ASP developers using the Logging
Application Block would want to do and therefore I expected to find a quick
and simple way to achieve it.
May 3 '06 #1
3 2563
I'm using it, and its pretty easy... Especially since aspnet 2.0 is using
the data access application block...

Simply install the latest Enterprise Library (January right now, but I think
that's going to change soon), then add three of the P&P Enterprise library
projects to your web project: Common, Logging and Object Builder. They're
located under
C:\Program Files\Microsoft Enterprise Library January
2006\src\ObjectBuilder, Logging and Common. Just right click on your web
solution, click Add existing project, and browse to these directories to add
the solution. If VS is hiding your solution-level node in your web project
you'll have to figure out how to show it. For some reason the VS team
decided to screw up web projects. Anyhow, once you've added the projects,
you can use the Enterprise Library Configuration tool to open up your
web.config and add the configuration settings for your log. Set up a
different category source for each type of event you want to log (Audits,
security, data access, exeptions, general, etc). Point each one to your
default trace listener (which should be the formatted event log trace
listener). Last thing is to investigate Logger.Write and Tracer -- those are
the two objects you'll use most. That's about it. Now, if you want to sign
your web project, you might run into some problems. I haven't investigated
that process fully, so I can't help you there.

"Dick" wrote:
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 System.Diagnostics Tracing as described in
http://msdn2.microsoft.com/en-us/lib...xd(VS.80).aspx. But I would
have thought this is something most ASP developers using the Logging
Application Block would want to do and therefore I expected to find a quick
and simple way to achieve it.

May 3 '06 #2
Thanks William.

I hate to say it (after you wrote all those helpful words) but I've already
installed and am successfully using the Logging Application Block. It works
really well within my Windows Application. My question was related to its use
within ASP.net.

I want to continue using the ASP.net tracing facilities, i.e. I still want
to use Trace.axd. But I want to use the Logging Application Block as well.
But I don’t want to have two separate logging mechanisms - I want to
integrate the two! The article I mentioned in my earlier post describes how
to do this when using System.Diagnostics.Tracing but I havn't found anything
that describes the same for the Logging Application Block.

May 3 '06 #3
Hi Richard,

As for the ASP.NET 2.0, it does provide simplified approach for us to
router/redirect trace message between the diagnostic trace and asp.ne
Trace. However, the redirection is depend on the underlying interface
support. For example, Diagnostic trace provide the <listeners> section to
let us register other listener so that we can redirect disgnostic trace to
ASP.NET page trace. However, if what you want is redirecting the logging
application block's trace to the asp.net page trace, I think this depend on
the interface and customization feature of the Logging Applcation block,
have you checked to see whether the 2.0 logging block provide such
configuration to plug a custom output listener?

Anyway, we can write trace to page TraceContext in our own class library
through the HttpContext.Current property. And the built-in
WebPageTraceListner just use the following code to flush trace into WebPage
TraceContext:

===================
public override void TraceEvent(TraceEventCache eventCache, string source,
TraceEventType severity, int id, string message)
{
if ((base.Filter == null) || base.Filter.ShouldTrace(eventCache,
source, severity, id, message, null, null, null))
{
HttpContext context1 = HttpContext.Current;
if (context1 != null)
{
string text1 = string.Concat(new object[] {
SR.GetString("WebPageTraceListener_Event"), " ", id, ": ", message });
if (severity <= TraceEventType.Warning)
{
context1.Trace.WarnInternal(source, text1, false);
}
else
{
context1.Trace.WriteInternal(source, text1, false);
}
}
}
}
======================

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

May 4 '06 #4

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

Similar topics

0
by: Joe Bloggs | last post by:
Hi all, I take the pleasure to inform that Dotnet Commons Logging has been released for use. Dotnet Commons Logging, a subproject of the Donet Commons project currently located under the...
0
by: Ollie Riches | last post by:
I have managed to get asycnhronous logging work for an asp.net application and I wanted some clarification on the method. Normally if the application is logging synchronously it has all the...
3
by: Karuppasamy | last post by:
Hi I am trying to use the Logging Module provided by Microsoft Application Blocks for .Net . I installed everything as per the Instructions given in the 'Development Using the Logging Block'. ...
6
by: Kevin Jackson | last post by:
Let's say we log exceptions to the windows application event log using the Exception Management Application Block. Is there a pattern that can be used so the exception is logged only once and not...
16
by: Einar Høst | last post by:
Hi, I'm getting into the Trace-functionality in .NET, using it to provide some much-needed logging across dlls in the project we're working on. However, being a newbie, I'm wondering if some...
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...
0
by: rajesh.hanchate | last post by:
Please help me in resolving this issue. I am using EnterpriseLibrary 2.0 Exception and logging block for logging exceptions to event log. It works fine for sometime. After some time it stops...
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...
5
by: Daniel S | last post by:
Hi, I'm new here. I'm using the Logging Application Block with Enterprise Library 3.1. My program works correctly on my XP developer station, but on the 2003 Server, no new entries appear in...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.