Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8272465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:07:56+00:00 2026-06-08T07:07:56+00:00

I’m using mongodb to store application error logs as json documents. I want to

  • 0

I’m using mongodb to store application error logs as json documents. I want to be able to format the error logs as HTML rather than returning the plain json to the browser. The logs are properly schemaless – they could change at any time, so it’s no use trying to do this (in Jade):

    - var items = jsonResults

    - each item in items
        h3 Server alias: #{item.ServerAlias}
        p UUID: #{item.UUID}
        p Stack trace: #{item.StackTrace}
            h3 Session: #{item.Session}
            p URL token: #{item.Session.UrlToken}
            p Session messages: #{item.Session.SessionMessages}

as I don’t know what’s actually going to be in the JSON structure ahead of time. What I want is surely possible, though? Everything I’m reading says that the schema isn’t enforced by the database but that your view code will outline your schema anyway – but we’ve got hundreds of possible fields that could be removed or added at any time so managing the views in this way is fairly unmanageable.

What am I missing? Am I making the wrong assumptions about the technology? Going at this the wrong way?


Edited with extra info following comments:

The json docs look something like this

{
   "ServerAlias":"GBIZ-WEB",
   "Session":{
      "urltoken":"CFID=10989&CFTOKEN=f07fe950-53926E3B-F33A-093D-3FCEFB&jsessionid=84303d29a229d1",
      "captcha":{

      },
      "sessionmessages":{

      },
      "sessionid":"84197a667053f63433672873j377e7d379101"
   },
   "UUID":"53934LBB-DB8F-79T6-C03937JD84HB864A338",
   "Template":"\/home\/vagrant\/dev\/websites\/g-bis\/code\/webroot\/page\/home\/home.cfm, line 3",
   "Error":{
      "GeneratedContent":"",
      "Mailto":"",
      "RootCause":{
         "Message":"Unknown tag: cfincflude.",
         "tagName":"cfincflude",
         "TagContext":[
            {
               "RAW_TRACE":"\tat cfhome2ecfm1296628853.runPage(\/home\/vagrant\/dev\/websites\/nig-bis\/code\/webroot\/page\/home\/home.cfm:3)",
               "ID":"CFINCLUDE",
               "TEMPLATE":"\/home\/vagrant\/dev\/websites\/nig-bis\/code\/webroot\/page\/home\/home.cfm",
               "LINE":3,
               "TYPE":"CFML",
               "COLUMN":0
            },
            {
               "RAW_TRACE":"\tat cfdisplay2ecfm1093821753.runPage(\/home\/vagrant\/dev\/websites\/nig-bis\/code\/webroot\/page\/display.cfm:6)",
               "ID":"CFINCLUDE",
               "TEMPLATE":"\/home\/vagrant\/dev\/websites\/nig-bis\/code\/webroot\/page\/display.cfm",
               "LINE":6,
               "TYPE":"CFML",
               "COLUMN":0
            }
         ]
       }
   }

… etc, but is likely to change depending on what the individual project that generates the log is configured to trigger.

What I want to end up with is a formatted HTML page with headers for each parent and the children listed below, iterating right through the data structure. The Jade sample above is effectively what we need to output, but without hard-coding that in the view.

Mike’s analysis in the comments of the problem being that of creating a table-like structure from a bunch of collections that haven’t really got a lot in common is bang-on. The data is relational, but only within individual documents – so hard-coding the schema into anything is virtually impossible as it requires you to know what the data structure looks like first.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:07:57+00:00Added an answer on June 8, 2026 at 7:07 am

    The basic idea is what @Gates VP described. I use underscore.js to iterate through the arrays/objects.

    function formatLog(obj){
      var log = "";
      _.each(obj, function(val, key){ 
        if(typeof(val) === "object" || typeof(val) === "array"){
          // if we have a new list
          log += "<ul>";
          log += formatLog(val);
          log += "</ul>";
        }
        else{
          // if we are at an endpoint
          log += "<li>";
          log += (key + ": " + val);
          log += "</li>";
        }
      });
      return log;
    }
    

    If you call formatLog()on the example data you gave it returns

    • ServerAlias: GBIZ-WEB
    • urltoken: CFID=10989&CFTOKEN=f07fe950-53926E3B-F33A-093D-3FCEFB&jsessionid=84303d29a229d1
      • sessionid: 84197a667053f63433672873j377e7d379101
      • UUID: 53934LBB-DB8F-79T6-C03937JD84HB864A338
      • Template: /home/vagrant/dev/websites/g-bis/code/webroot/page/home/home.cfm, line 3
        • GeneratedContent:
        • Mailto:
        • Message: Unknown tag: cfincflude.
        • tagName: cfincflude
          • RAW_TRACE: at cfhome2ecfm1296628853.runPage(/home/vagrant/dev/websites/nig-bis/code/webroot/page/home/home.cfm:3)
          • ID: CFINCLUDE
          • TEMPLATE: /home/vagrant/dev/websites/nig-bis/code/webroot/page/home/home.cfm
          • LINE: 3
          • TYPE: CFML
          • COLUMN: 0
          • RAW_TRACE: at cfdisplay2ecfm1093821753.runPage(/home/vagrant/dev/websites/nig-bis/code/webroot/page/display.cfm:6)
          • ID: CFINCLUDE
          • TEMPLATE: /home/vagrant/dev/websites/nig-bis/code/webroot/page/display.cfm
          • LINE: 6
          • TYPE: CFML
          • COLUMN: 0

          How to format it then is up to you.

        • 0
        • Reply
        • Share
          Share
          • Share on Facebook
          • Share on Twitter
          • Share on LinkedIn
          • Share on WhatsApp
          • Report

        Sidebar

        Related Questions

        I'm new to using the Perl treebuilder module for HTML parsing and can't figure
        link Im having trouble converting the html entites into html characters, (&# 8217;) i
        I have thousands of HTML files to process using Groovy/Java and I need to
        That's pretty much it. I'm using Nokogiri to scrape a web page what has
        I want to count how many characters a certain string has in PHP, but
        I am reading a book about Javascript and jQuery and using one of the
        I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
        I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
        I want use html5's new tag to play a wav file (currently only supported
        I have this code to decode numeric html entities to the UTF8 equivalent character.

        Explore

        • Home
        • Add group
        • Groups page
        • Communities
        • Questions
          • New Questions
          • Trending Questions
          • Must read Questions
          • Hot Questions
        • Polls
        • Tags
        • Badges
        • Users
        • Help
        • SEARCH

        Footer

        © 2021 The Archive Base. All Rights Reserved
        With Love by The Archive Base

        Insert/edit link

        Enter the destination URL

        Or link to existing content

          No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.