473,773 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.FileS tream ts = new
System.IO.FileS tream(traceFile ,System.IO.File Mode.Append);
Trace.Listeners .Remove
(Trace.Listener s[0]);
Trace.Listeners .Add(new
TextWriterTrace Listener(ts));
Trace.WriteLine ("Constructo r " +
System.DateTime .Now.ToString() );
Trace.Close();

[WebMethod]
public WebMethod ()
{
System.IO.FileS tream ts = new
System.IO.FileS tream(traceFile ,System.IO.File Mode.Append);
Trace.Listeners .Remove
(Trace.Listener s[0]);
Trace.Listeners .Add(new
TextWriterTrace Listener(ts));
Trace.WriteLine ("Method " +
System.DateTime .Now.ToString() );
Trace.Close();
}
Nov 11 '05 #1
2 6132
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******@nowhe re.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.FileS tream ts = new
System.IO.FileS tream(traceFile ,System.IO.File Mode.Append);
Trace.Listeners .Remove
(Trace.Listener s[0]);
Trace.Listeners .Add(new
TextWriterTrace Listener(ts));
Trace.WriteLine ("Constructo r " +
System.DateTime .Now.ToString() );
Trace.Close();

[WebMethod]
public WebMethod ()
{
System.IO.FileS tream ts = new
System.IO.FileS tream(traceFile ,System.IO.File Mode.Append);
Trace.Listeners .Remove
(Trace.Listener s[0]);
Trace.Listeners .Add(new
TextWriterTrace Listener(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
3429
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 is the recursive child of the first subsequent dep=n database call listed in the SQL data stream. The book gives a few examples, and in trying it out it seemed to work until I tried the following SQL. My question are why does this not keep with...
0
324
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 locked state. Thus, the next time the service is started, it fails because it cannot reopen the text file. Has anyone experienced this? Does anyone have fixes or can you suggest more robust code for handling
3
2618
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 at certain points while executing. The monitoring app I want to write will be very simple, just picking up these traces and displaying them to show progress of the service. My question is what is the best method of communication between the...
1
1924
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
2781
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 trace for the input and output calls and answers to the web service. I've downloaded WSE 2.0 tool since i use .net vs 2003, c#. I've desperately been trying to get a trace with no success.
12
6063
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 is apparently the correct way forward nobody offers a solution as to how it is actually done. I gather that code like:
2
2535
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 thoughts?
3
2070
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 its log on the new server. As part of the redeployment, I created the event log on the server for the Web service to write to, so I don't understand what the problem can be. I also checked the permissions on the Web service and couldn't find...
0
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9914
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.