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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Logging asynchronously

Logging asynchronously

Scheduled Pinned Locked Moved C#
data-structuresquestion
5 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
    Michel Rainville
    wrote on last edited by
    #1

    Hi I need a logging framework that let me log asynchronously. Do you have any suggestion ? I tried to figure out if log4net does all the logging asynchronously. Does it depend on a specific Appender or all logging is done asynchronously ? I did a test in which I log 1500 time the same string. - Log4net with FileAppender is doing it in approx. between 100 and 200 miliseconds; - Log4net with BufferingForwardingAppender combine with FileAppender is doing it in approx. 2000 miliseconds; - System.IO does it in approx. 10 miliseconds. I also tried with EIF using my own EventSink sending all request in a MSMQ queue but using EIF is not as easy to deploy as log4net so... Any suggestion would be appreciate

    H D 2 Replies Last reply
    0
    • M Michel Rainville

      Hi I need a logging framework that let me log asynchronously. Do you have any suggestion ? I tried to figure out if log4net does all the logging asynchronously. Does it depend on a specific Appender or all logging is done asynchronously ? I did a test in which I log 1500 time the same string. - Log4net with FileAppender is doing it in approx. between 100 and 200 miliseconds; - Log4net with BufferingForwardingAppender combine with FileAppender is doing it in approx. 2000 miliseconds; - System.IO does it in approx. 10 miliseconds. I also tried with EIF using my own EventSink sending all request in a MSMQ queue but using EIF is not as easy to deploy as log4net so... Any suggestion would be appreciate

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      The EIF offers more than just logging using the EIF. What you're logging to, however, greatly matters unless you're queuing requests in order and flushing them to disk or some other sequential data store. Note that a simple solution is to define a delgate on the logging method and execute that asynchronously. The backing store matters, however, because doing things this way with a non-thread-safe backing store could cause major problems. For example:

      internal delegate void Log(string message, string category);
      // ...
      Log log = new Log(Trace.WriteLine);
      log.BeginInvoke(message, category, null, null);

      It's an overly simplified example, but hopefully gives you the idea. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles]

      1 Reply Last reply
      0
      • M Michel Rainville

        Hi I need a logging framework that let me log asynchronously. Do you have any suggestion ? I tried to figure out if log4net does all the logging asynchronously. Does it depend on a specific Appender or all logging is done asynchronously ? I did a test in which I log 1500 time the same string. - Log4net with FileAppender is doing it in approx. between 100 and 200 miliseconds; - Log4net with BufferingForwardingAppender combine with FileAppender is doing it in approx. 2000 miliseconds; - System.IO does it in approx. 10 miliseconds. I also tried with EIF using my own EventSink sending all request in a MSMQ queue but using EIF is not as easy to deploy as log4net so... Any suggestion would be appreciate

        D Offline
        D Offline
        Daniel3000i
        wrote on last edited by
        #3

        Log4Net looks suspiciously like Log4J. Easy to use; but a hog and will slow your program down. In Log4J there are asynchronous appenders, look for the same in Log4Net. You should see some increase in speed; but I wouldn't expect any logging framework to be faster or even as fast as System.IO. Daniel

        M 1 Reply Last reply
        0
        • D Daniel3000i

          Log4Net looks suspiciously like Log4J. Easy to use; but a hog and will slow your program down. In Log4J there are asynchronous appenders, look for the same in Log4Net. You should see some increase in speed; but I wouldn't expect any logging framework to be faster or even as fast as System.IO. Daniel

          M Offline
          M Offline
          Michel Rainville
          wrote on last edited by
          #4

          Thanks for your reply Daniel I have a couple of question regarding what you just said: 1- Can you tell what are the appender that you know is asynchronous (in Log4J at least) 2- Why would you expect System.IO to be faster ? I understand that there is a cost (overhead) to use this kind of framework but if the appender is sending message (logging event) to a structure that it is store in memory, I expect it to be faster than an IO on disk. Am I wrong Daniel. If I recall my first post, this is exactly what I did using EIF and a specific EventSink (appender). My EventSynk only take the logging event and put it on an MSMQ and return very fast (but telling that remind me that I did not save the metrics for that one, so how fast it realy is... I'll tell you) Anyway, Thank you to both of you who reply to this post. I can't believe that in 2004 I'm still worry about logging Thanks again Michel

          D 1 Reply Last reply
          0
          • M Michel Rainville

            Thanks for your reply Daniel I have a couple of question regarding what you just said: 1- Can you tell what are the appender that you know is asynchronous (in Log4J at least) 2- Why would you expect System.IO to be faster ? I understand that there is a cost (overhead) to use this kind of framework but if the appender is sending message (logging event) to a structure that it is store in memory, I expect it to be faster than an IO on disk. Am I wrong Daniel. If I recall my first post, this is exactly what I did using EIF and a specific EventSink (appender). My EventSynk only take the logging event and put it on an MSMQ and return very fast (but telling that remind me that I did not save the metrics for that one, so how fast it realy is... I'll tell you) Anyway, Thank you to both of you who reply to this post. I can't believe that in 2004 I'm still worry about logging Thanks again Michel

            D Offline
            D Offline
            Daniel3000i
            wrote on last edited by
            #5

            1. In Log4J you can use something called AsyncAppender. It takes references to already instantiated Appenders and uses them to write asynchronously. 2. Your are not wrong about writing to memory being faster than writing to disk. But, if your ultimate goal is to have another layer of abstraction manage logging to disk for you faster than using System.IO you probably won't find anything that can. It won't be faster because that extra layer of abstraction will necessarily add some time to processing your logging plus writing the information to disk later. Daniel

            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