From time to time a developer has some p开发者_StackOverflowarameters or variables that s/he wants to write to a log line, console output, or in my case database view.
How would you format such a string to be the most readable?
Examples:
ID=123, Name=John, Link=http://www.bestsitever.com/askjd.aspx?acz=23&345, Happy=true
[ID: 123], [Name: John], [Link: http://www.bestsitever.com/askjd.aspx?acz=23&345], [Happy: true]
What would be the recommended / best practice format? I just can't get my string to be.. readable :)
JSON. A hybrid. Both quite easy to read and easy to parse.
Personnally, when I have to extract and maipulate log data I do it in Microsoft Excel, so I format my log data to be able to import them easily by setting an Excel separator like tab
, ;
or ,
to separate the different pieces. This way when I import them throught the import data from a text file, Excel create a distinct column for each part of every log line.
In my debugging logs I tend to dump a lot of informations like the URL query, all the URL/Session params, the user agent and the general error and multiple line breaks message which looks like :
2011-05-05T08:39:37-04:00 CRIT (2):
Exception information :
... error message
Stack trace :
... full stacktrace
Query params (Zend) :
array (
...
)
Query params (Full) :
array(
...
)
Web browser informations :
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
I also tend to breakdown my debugging logs by date, this way if my debugging log reach many Kb, I know that at that particular date there is something wrong.
精彩评论