Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Effective way of writing logs in web service in C#.net

Effective way of writing logs in web service in C#.net

Scheduled Pinned Locked Moved C#
questioncsharpdatabasedebugginghelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    manishchourasia2000
    wrote on last edited by
    #1

    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

    E J 2 Replies Last reply
    0
    • M manishchourasia2000

      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

      E Offline
      E Offline
      Elegantly Wasted
      wrote on last edited by
      #2

      Hi, This is just a suggestion to use Log4Net for tracing purpose Link :- Log4Net Hope this helps !!

      1 Reply Last reply
      0
      • M manishchourasia2000

        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

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups