Let's say that we want to log some information about what is happening in our application; rather than displaying it to the user. We should store this in a file that we can read either manually or via another interface, for example, in an administration application we might want to build.
Let's create the simplest code for this:
1. First off, let's create a folder to keep our logs. In
<Railo Installation>/webroot/Chapter_8/
, create a folder namedlogs
2. Now, let's write some code to append to a log file inside it (we haven't created any files inside it, but Railo Server will take care of it). Create a file in
<Railo Installation>/webroot/Chapter_8/
namedlisting_8_01.cfm
and add the following:<cffile action="append" file="logs/mylog.txt" output="This is the output to our log file! #Now()#">
3. If we now load up the script a few times by going to
http://localhost:8888/Chapter_8/listing_8_01.cfm
, we can populate our log file and...