I would like to share a small TIP which may help you all in recording errorLog in text file.
I have written a piece of code like –
************************************************************
// File to write the error log // file_to_search = 'c:testFile.txt'; // Details about the error to log // savecontent variable="data" { WriteOutput('
' & "--------------------------"); WriteOutput('
' & 'DATE/TIME: '); WriteOutput('
' & 'ERROR MESSAGE:'); WriteOutput('
' & 'ERROR DETAILS: '); WriteOutput('
' & 'ERROR TEMPLATE: '); WriteOutput('
' & 'ERROR LINE: '); WriteOutput('
' & 'ERROR TYPE: '); WriteOutput('
' & 'EVENTNAME: '); WriteOutput('
' & 'STACKTRACE: '); WriteOutput('
' & "---------------------"); } // Displaying error details on browser // writeOutput(data);
********************************************************************
You can run the code in test page..
1. When you execute the above page you can see the below output in browser.
————————————————— DATE/TIME: ERROR MESSAGE: ERROR DETAILS: ERROR TEMPLATE: ERROR LINE: ERROR TYPE: EVENTNAME: STACKTRACE:
—————————————————
2. But if you open the file ‘c:testFile.txt’ you may not see the same output.
3. Here the “
” tag will NOT gives you line break in text file.
4. It may seems ODD !!.
5. For that we need to use the ASCII combination of ENTER KEY to write the contents properly in text file.
Here is the below code which writes properly in ‘c:testFile.txt’.
//File to write the error log // file_to_search = 'c:testFile.txt'; // Details about the error to log // savecontent variable="data" { WriteOutput(Chr(13) & Chr(10) & "---------------"); WriteOutput(Chr(13) & Chr(10) & 'DATE/TIME: '); WriteOutput(Chr(13) & Chr(10) & 'ERROR MESSAGE:'); WriteOutput(Chr(13) & Chr(10) & 'ERROR DETAILS: '); WriteOutput(Chr(13) & Chr(10) & 'ERROR TEMPLATE: '); WriteOutput(Chr(13) & Chr(10) & 'ERROR LINE: '); WriteOutput(Chr(13) & Chr(10) & 'ERROR TYPE: '); WriteOutput(Chr(13) & Chr(10) & 'EVENTNAME: '); WriteOutput(Chr(13) & Chr(10) & 'STACKTRACE: '); WriteOutput(Chr(13) & Chr(10) & "---------------"); }
6. Please note that we should use the combination of Chr(13) & Chr(10) for ENTER key. That is line break and carriage return. If you use only Chr(13) will not give a line break in text file.