I was asked to write a log searching app that will...
# cfml-beginners
e
I was asked to write a log searching app that will search a directory (or many directories) of log files and output a list of logs with word "error" in it. Anyone tried it before. I found <cfsearch> on Adobe site. Does it work well? Any other ideas?
d
Not log files, I have digested many simple text files similar to log files.
Copy code
var lines = fileRead("./output.log").listToArray(chr(13) & chr(10));
for( l in lines ){
   // Digest one line at a time.
}
a
I think it's probably overkill putting a full-text search engine over a requirement to find matches for "error" in some log files. You're a bit light on detail & intent & context to be able to answer sensibly, I think. But you should just start solving the problem. Do whatever is within your capabilities to implement now. And worry about improving it after you deliver a MVP. I'd just loop over the list of dirs, get a file listing of the *.log files, and read the files looking for "error". You don't tell us how many directories, where they are located, how many files, how big they are etc. Which is all baseline information for making an informed decision as to how to approach this.
e
Thank you for quick responses. I do not know all requirements at this time. I am asking this question to save myself time once I do know them. As you suggested, I will start with getting a list of files in dir
d
Download log viewing apps and see which features you like and that you can implement yourself. Or just use one of those apps or services. lol. Could be cheaper.
p
Reading all the lines of a file and looping over it will be slow.
e
Thank you Paul, but we're on Windows