Write trace information to sql server database in web service

  • Thread starter Thread starter Andrus
  • Start date Start date
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.
 
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
 
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.
 
Back
Top