Effective way of writing logs in web service in C#.net
-
Hi all, I want to know what is the effective to way to write logs in web service. I personally feel that we should log this to flat files instead of database using Trace Listener. Writing a snippet for logging is not a big deal, but calling that method classes is bit laborous. I am bit worry for the following queries. 1. Do I need to write log (calling function to write log) after each line in all the method. 2. If I enable logging level 1,2,3 etc (class level, method level & line level) how do I write a log. 3. What would be the content of log so that I can track the exact error / warning / info. Can anybody flow their knowledge / opennion ?
s
-
Hi all, I want to know what is the effective to way to write logs in web service. I personally feel that we should log this to flat files instead of database using Trace Listener. Writing a snippet for logging is not a big deal, but calling that method classes is bit laborous. I am bit worry for the following queries. 1. Do I need to write log (calling function to write log) after each line in all the method. 2. If I enable logging level 1,2,3 etc (class level, method level & line level) how do I write a log. 3. What would be the content of log so that I can track the exact error / warning / info. Can anybody flow their knowledge / opennion ?
s
Hi, This is just a suggestion to use Log4Net for tracing purpose Link :- Log4Net Hope this helps !!
-
Hi all, I want to know what is the effective to way to write logs in web service. I personally feel that we should log this to flat files instead of database using Trace Listener. Writing a snippet for logging is not a big deal, but calling that method classes is bit laborous. I am bit worry for the following queries. 1. Do I need to write log (calling function to write log) after each line in all the method. 2. If I enable logging level 1,2,3 etc (class level, method level & line level) how do I write a log. 3. What would be the content of log so that I can track the exact error / warning / info. Can anybody flow their knowledge / opennion ?
s
manishchourasia2000 wrote:
I want to know what is the effective to way to write logs in web service
Effective is a loaded word. If you have specifics objective requirements then you should determine what those are first.
manishchourasia2000 wrote:
I personally feel that we should log this to flat files instead of database using Trace Listener
First, you might want to define exactly what "log" means. My criteria - I differentiated between 'development' logs and 'business' logs. - Development logs are solely and completely intended to help developers debug problems that occurred during production. - Development logs are NOT intended to be 'easy' tools for IT or support to figure out problems. Logs can exist for those purposes but those are business logs (a type of business log.) - IT and support are welcome to use development logs and can make suggestions for either adding or removing content but they do not dictate it. - Development logs are NOT intended to provide support for developing code. A developer might use it when actually doing the development but what remains in the delivered code must be suited for use in production. And example of this that logs can not have things like "Now in the loop" or print out every time a polling loop is entered. - Failures in the development logs cannot stop the business functionality from running. - Business logs should be handled like any other business requirement where a product owner delivers requirements for it, development implements it, and QA validates it. Failure to write a business log can stop business functionality. That should be specified as part of the requirements A business log(s) might include things like the following - A user logged in - A user deleted a record - The IP a user request came from. - Expected errors which are not reported via other mechanisms. Finally a log cannot exist solely in a database because writing to the database might fail
manishchourasia2000 wrote:
Writing a snippet for logging is not a big deal
Use a 3rd party library. As per the other response for Log4net or I have used NLog. You might want to actually research logging libraries. One criteria I used the last time was how active the log library updates were. At least when I looked years ago log4net was not being actively maintained while NLog was. That co