Let's change our code in the listing_8_01.cfm
template to loop through the contents of a file; this will allow us to have a bit more control over what we do with the output.
1. Edit
listing_8_01.cfm
, remove the<cffile action="read">
, and let's use a loop to display each line of the code:<cffile action="append" file="logs/mylog.txt" output="This is the output to our log file! #Now()#"> <cfloop file="logs/mylog.txt" index="i"> <cfoutput>#i#</cfoutput><br> </cfloop>
2. If you now run the template by going to
http://localhost:8888/Chapter_8/listing_8_01.cfm
, you will get each line outputted nicely. You could now parse each line.