Write trace information to sql server database in web service

A

Andrus

I need to output trace information in web service methods. We service is
located in web page hosting company server.
So I think best way it to create trace listener as TraceListener class child
class which writes trace infomation to logfile table in server database.

Where to find sample code for this ?

Andrus.
 
A

Alberto Poblacion

Andrus said:
I need to output trace information in web service methods. We service is
located in web page hosting company server.
So I think best way it to create trace listener as TraceListener class
child class which writes trace infomation to logfile table in server
database.

There may be an easier way. You could use the HealthMonitoring API to
write events to a database by means of the SqlWebEventProvider class. In
this way, you would not need to create the trace listener yourself.
http://msdn.microsoft.com/en-us/library/system.web.management.sqlwebeventprovider.aspx
 
A

Alberto Poblacion

Andrus said:
Alberto,


Thank you.
My server is PostgreSql.
How to write to PostgreSql server ?


Ah, no. Then you can't use the SqlWebEventProvider. You could, of course,
write your own provider, but I don't think it's worth the trouble. If you
are going to do that, you might as well go with your initial idea of
creating a TraceListener. I've never done it, but it should be reasonably
straightforward: just inherit from the abstract base class TraceListener,
and override all the required members. Inside your overrides you will have
to open your own connection to PostgreSql and write into your log table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top