Thanks

 

I thought reflection would be the only way one could discover how to handle
this.  I could use reflector to handle this.

 

However I have spent too much time on this and its a nice to have so I m
going to put it on the back burner.

 

I can set up the client web proxy entirely in code.

I an create an XmlWriterTraceListener in code.

 

I just don't know how to bind them together so that wcf emits all the trace
information.

 

I would say if its too hard to find out, probably very few have a need for
this in production.

 

In development one can use app.config to set it up with the very nice wcf
configuration editor.

 

Regards Peter

 

From: [email protected] [mailto:[email protected]]
On Behalf Of Matt Siebert
Sent: Wednesday, 9 March 2011 9:41 AM
To: ozDotNet
Subject: Re: WCF TraceListeners

 

I'd be really interested if there's a way to do this without the config
file.  I've already used these traces to fix an issue in development, and
it'd be nice to be able to easily enable / disable this stuff out in the
wild.

 

I'm not totally familiar with the tracing system, but I've been working with
TraceListeners lately thanks to Enterprise Library's Logging Application
Block...

 

The only way I can see to do this in code is to use reflection to get to the
static DiagnosticTrace property on System.ServiceModel.DiagnosticUtility.
The DiagnosticTrace type has a TraceSource property which looks like it'll
allow you to configure the "System.ServiceModel" source, but I'm not sure if
DiagnosticTrace will be created if there's nothing in the config file.

 

It always frustrates me to see things that can only be configured by the
config file, or when you can only ever find info on using the config files
and nothing for configuring stuff in code.  I'm often coding for scenarios
where I wouldn't want a user to change certain settings (i.e. WCF) so I have
to do things in code and I'll generally provide a custom config section just
for the things I'm will to expose.

 

That said, aside from a potential performance hit, tracing shouldn't really
affect the app's functionality so I wouldn't be too concerned if it had to
be exposed in the config file (although it is rather frustrating).  If there
is nothing in System.Configuration to help achieve this, then you could just
code something to update the file as plain old XML (again, frustrating).
Obviously, you'd still have to worry about permissions / elevation for
writing to the file and restarting your app to use the new settings, or
maybe TraceSource.Refresh() will work...

 

On Tue, Mar 8, 2011 at 7:08 PM, Peter Maddin <[email protected]>
wrote:

I can set up my wcf client proxy class in code.

 

 
I can set up a Trace Listener in particular I would like to use the default
XmlWriterTraceListener. There does not seem to be any way of intregrating a
wcf client proxy with a trace listener short of
building a custom tracelistener and integrating this via the app.config
file. The very thing I am trying to avoid.
 
 
I am not sure why it needs to be this difficult or hard.
 
 
There must be a way of doing this so that this incredibly useful diagnostic
tool can be used in a production environment at a client's site.
 
At http://msdn.microsoft.com/en-us/library/ms733025.aspx
 
It states

Windows Communication Foundation (WCF) outputs the following data for
diagnostic tracing:

.         Traces for process milestones across all components of the
applications, such as operation calls, code exceptions, warnings and other
significant processing events.

.         Windows error events when the tracing feature malfunctions. See
<http://msdn.microsoft.com/en-us/library/ms733738.aspx> Event Logging.

WCF tracing is built on top of
<http://msdn.microsoft.com/en-us/library/system.diagnostics.aspx>
System.Diagnostics. To use tracing, you should define trace sources in the
configuration file or in code. WCF defines a trace source for each WCF
assembly. The System.ServiceModel trace source is the most general WCF trace
source, and records processing milestones across the WCF communication
stack, from entering/leaving transport to entering/leaving user code. The
System.ServiceModel.MessageLogging trace source records all messages that
flow through the system.

 
Well it says "or in code", but how to do this in code is as elusive as ever.
 
Regards Peter

 

 

Regards Peter Maddin
Applications Development Officer
PathWest Laboratory Medicine WA
Phone : +618 6396 4285
Mobile: 0414 240 307 
E-Mail : [email protected]; [email protected]
The contents of this e-mail transmission outside of the WAGHS network are
intended solely for the named recipient's), may be confidential, and may be
privileged or otherwise protected from disclosure in the public interest.
The use, reproduction, disclosure or distribution of the contents of this
e-mail transmission by any person other than the named recipient(s) is
prohibited. If you are not a named recipient please notify the sender
immediately.

 

 

 

Reply via email to