473,396 Members | 1,918 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,396 software developers and data experts.

Writing to one trace file from Web Service

Presumably a trivial question...
I want to write trace information from a web service to a
log file using the Trace Class. Is this possible without
closing and opening the Trace in every single web method?

Code:
public Webservice()
System.IO.FileStream ts = new
System.IO.FileStream(traceFile,System.IO.FileMode. Append);
Trace.Listeners.Remove
(Trace.Listeners[0]);
Trace.Listeners.Add(new
TextWriterTraceListener(ts));
Trace.WriteLine("Constructor " +
System.DateTime.Now.ToString());
Trace.Close();

[WebMethod]
public WebMethod ()
{
System.IO.FileStream ts = new
System.IO.FileStream(traceFile,System.IO.FileMode. Append);
Trace.Listeners.Remove
(Trace.Listeners[0]);
Trace.Listeners.Add(new
TextWriterTraceListener(ts));
Trace.WriteLine("Method " +
System.DateTime.Now.ToString());
Trace.Close();
}
Nov 11 '05 #1
2 6106
Maybe you need to add the relevant objects to application state or session
state or whatever is appropriate.
Then when a web method is invoked, retrieve the objects and use them.

--
Dino Chiesa
Microsoft Developer Division
d i n o c h @ o n l i n e . m i c r o s o f t . c o m

"Wilfried Hoermann" <nn******@nowhere.com> wrote in message
news:0f****************************@phx.gbl...
Presumably a trivial question...
I want to write trace information from a web service to a
log file using the Trace Class. Is this possible without
closing and opening the Trace in every single web method?

Code:
public Webservice()
System.IO.FileStream ts = new
System.IO.FileStream(traceFile,System.IO.FileMode. Append);
Trace.Listeners.Remove
(Trace.Listeners[0]);
Trace.Listeners.Add(new
TextWriterTraceListener(ts));
Trace.WriteLine("Constructor " +
System.DateTime.Now.ToString());
Trace.Close();

[WebMethod]
public WebMethod ()
{
System.IO.FileStream ts = new
System.IO.FileStream(traceFile,System.IO.FileMode. Append);
Trace.Listeners.Remove
(Trace.Listeners[0]);
Trace.Listeners.Add(new
TextWriterTraceListener(ts));
Trace.WriteLine("Method " +
System.DateTime.Now.ToString());
Trace.Close();
}

Nov 11 '05 #2
Maybe you could be a little bit more specific.

I have got a File(stream) and the Trace Utility Class with
the TraceListeners Collection.
I want to add the File to the TraceListeners and write
Trace output from various Webmethods to it.

How could I achieve this?
Nov 11 '05 #3

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

Similar topics

2
by: Oxmard | last post by:
Armed with my new O'Reilly book Optimizing Oracle Performance I have been trying to get a better understanding of how Oracle works. The book makes the statement, " A database cal with dep=n + 1...
0
by: John Bailo | last post by:
I added a trace file listener to a web service to record when the service is accessed and print exceptions. I find that almost every time after the web service runs, the .trace file is left in a...
3
by: Chris Dunaway | last post by:
I am writing a Windows Service that reads and processes files on a set schedule. I want to create a second app that can monitor the Windows service. The Windows service will write trace messages...
1
by: newcomer | last post by:
I have traced action in XML. Now I would like to replay that. How could I do that based on this XML trace? I am using soap:tcp between client and server. thanks,
2
by: Albert | last post by:
Hi, I've recently had frustration experience using a certain web service provided by a known organization. In order to maybe get a response from the technical they want me to send them the XML...
12
by: Martyn Fewtrell | last post by:
Hi there I'm trying to find the correct way to write exceptions to the Application log using Vb.Net. I've done a fair bit of Googleing and although this gets plenty of mentions and that this...
2
by: Marc | last post by:
I'm building a Windows service that writes log messages via TraceListeners. I assume Trace.Close() is useful for garbage collection, but I'm not sure where to call it in the Windows service. Any...
3
by: Peter Bradley | last post by:
Hi, I have a Web Service that has been running on a server for a couple of years. I now have to redeploy it to another server. Everything is fine except that the Web Service cannot write to...
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
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.