1

Im developing application in this application, I have to show runtime logs whenever any update come it should show right way. I meant to say it should show log on coldfusion page just like console. I know it is possible with the help of AJAX but I don’t know how do in coldfusion. I don’t want to run scheduler every second. Is there any other way I can do this ?

If you need any more details or if im not clear please let me know …

Thanks

M.A
  • 448
  • 6
  • 21
  • I cannot tell what your question is as currently written. Voting to close, however if you edit your post with more details I will remove my vote. [Ask] – Miguel-F Aug 24 '15 at 23:59
  • Where does the log content come from? CF? If so you can use good old cfflush, or Server Sent Events or WebSocket. – Henry Aug 25 '15 at 05:39
  • Log files coming some other system completely different system ... – M.A Aug 25 '15 at 12:46
  • The question is still unclear. Are you saying the files reside on a different machine than the CF server? How are they accessed from the CF server machine? – Leigh Aug 25 '15 at 15:51
  • Yes it is shared drive where logs files other system saving my cf server also can see that directory, my task is to read those files and generate report runtime – M.A Aug 25 '15 at 15:55
  • You can use javascript's setTimeout method to do your scheduling. As far as reading the log files go, if they are too large you could run into java heap space errors. – Dan Bracuk Aug 25 '15 at 16:29
  • Hmm... I have to process the log before display I mean I have to insert in db and then I will show – M.A Aug 25 '15 at 16:40

1 Answers1

4

DirectoryWatcherGateway

The DirectoryWatcherGateway event gateway sends events to the listener CFC when a file is created, deleted, or modified in a directory. The watcher runs in a thread that sleeps for an interval specified in the configuration file, and when the interval has passed, checks for changes since the last time it was awake. If it finds added, deleted, or changed files, it sends a message to a listener CFC. You can configure separate CFCs for add, delete, and change events, or use a single CFC for all events. The source for this event gateway is located in the gateway/src/examples/watcher directory.

http://help.adobe.com/en_US/ColdFusion/10.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-77f7.html

Once it's detected modified (by polling), then you can return the last x number of lines using tail in Linux: https://stackoverflow.com/a/16375840/35634

Or Get-Content -tail in Window's Powershell https://technet.microsoft.com/en-gb/library/hh849787.aspx

Lastly, you may use Sever Sent Event (essentially ajax long polling) or cfwebsocket (CF10 or above) to push the last x lines to the client.

Community
  • 1
  • 1
Henry
  • 32,689
  • 19
  • 120
  • 221
  • your great... :) it looks good to me i can't wait to test ... maybe it is not 100% what im looking but you gave me right direction.... – M.A Aug 25 '15 at 18:37