By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,367 Members | 1,329 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,367 IT Pros & Developers. It's quick & easy.

Logging Application Block vs. System.Web.TraceContext

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.