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. XML / XSL
  4. XML Logging (Your thoughts)

XML Logging (Your thoughts)

Scheduled Pinned Locked Moved XML / XSL
htmlxmlquestiondiscussion
5 Posts 5 Posters 14 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I'm interested in implementing my applications log files as XML. From what little I know of XML, DOM requires that you load the entire document before you can manipulate nodes. Fine for reading, but if I'm logging a lot of items, I don't want to have to open the file, read the entire document, add a node, then close again. Does anyone have any experience doing XML logging? Is it worth the trouble? Got any examples or advice on non-DOM implementations?

    M E T 3 Replies Last reply
    0
    • L Lost User

      I'm interested in implementing my applications log files as XML. From what little I know of XML, DOM requires that you load the entire document before you can manipulate nodes. Fine for reading, but if I'm logging a lot of items, I don't want to have to open the file, read the entire document, add a node, then close again. Does anyone have any experience doing XML logging? Is it worth the trouble? Got any examples or advice on non-DOM implementations?

      M Offline
      M Offline
      Michael A Barnhart
      wrote on last edited by
      #2

      I would not use XML files for logging. They are text files as you state, open and closing all of the time. Some database would be better. You can then always export the database to an XML file when needed for processing or archiving. XML and related technologies are great but they are not pixie dust for all of the worlds troubles. To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli

      1 Reply Last reply
      0
      • L Lost User

        I'm interested in implementing my applications log files as XML. From what little I know of XML, DOM requires that you load the entire document before you can manipulate nodes. Fine for reading, but if I'm logging a lot of items, I don't want to have to open the file, read the entire document, add a node, then close again. Does anyone have any experience doing XML logging? Is it worth the trouble? Got any examples or advice on non-DOM implementations?

        E Offline
        E Offline
        Erik Westermann
        wrote on last edited by
        #3

        You could use one of two approaches if you do not plan to read the log file (only write to it):

        1. You could use the SAX interface to write entries to the log file
        2. You could write include XML tags in your log messages, making it possible to process the log later with an XML processor

        The second option is, by far, the easiest to implement. I wrote an article for another Web site back in November 2001 that covers most of option #1 - here's the link (new window): Using the Microsoft XML Parser to Create XML Documents Essam - Author, JScript .NET Programming
        ...and a bunch of articles around the Web

        1 Reply Last reply
        0
        • L Lost User

          I'm interested in implementing my applications log files as XML. From what little I know of XML, DOM requires that you load the entire document before you can manipulate nodes. Fine for reading, but if I'm logging a lot of items, I don't want to have to open the file, read the entire document, add a node, then close again. Does anyone have any experience doing XML logging? Is it worth the trouble? Got any examples or advice on non-DOM implementations?

          T Offline
          T Offline
          Todd Harvey
          wrote on last edited by
          #4

          here's what I did, but we didn't run this production yet 1) construct one line of valid xml 2) write it to text file , flush buffer This produced a text file that resembled xml, but missing the top-level node. To display it in a web page, I pre-pended a top-level node ( < TOP > ) , and appended a closing node name ( < / TOP > ), and this worked. I think one possible advantage is that it is super fast and simple to write a line of text, and then you can take care of the leading and trailing niceties later when you display the file. Also, this approach ignores the DOM entirely. It is only straight C text files at the time of logging. :rolleyes:

          D 1 Reply Last reply
          0
          • T Todd Harvey

            here's what I did, but we didn't run this production yet 1) construct one line of valid xml 2) write it to text file , flush buffer This produced a text file that resembled xml, but missing the top-level node. To display it in a web page, I pre-pended a top-level node ( < TOP > ) , and appended a closing node name ( < / TOP > ), and this worked. I think one possible advantage is that it is super fast and simple to write a line of text, and then you can take care of the leading and trailing niceties later when you display the file. Also, this approach ignores the DOM entirely. It is only straight C text files at the time of logging. :rolleyes:

            D Offline
            D Offline
            David Chamberlain
            wrote on last edited by
            #5

            We have done something similar, and for the first time files, if you check their existance before opening them, you can write out the xml header for a new file. You can also write out any trailer information, and if it is static, then when you open the file, you can re-position the file pointer (using fseek) to be that number of characters back from the end, write out your new data, and rewrite the static (ie, fixed/known length) trailer. It's a little clumsy, but it helps to know that you can re-position the file pointer. Dave "You can say that again." -- Dept. of Redundancy Dept.

            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