Enable or disable debugging output in Railo and Adobe Coldfusion

On my dev. server, I often need to switch the coldfusion administrator's 'debugging output' setting. Luckily, I can do it from a web page, with this nifty little script:


<cfparam name="url.debug" default="" />
<cfif len(url.debug)>
 <cfadmin type="server" action="updateDebug" password="*****" debug="#url.debug#" debugTemplate="/railo-context/templates/debugging/debugging.cfm" />
<!---are we in debug mode? --->
 <style type="text/css">
  * { font-size:12px; font-family:Verdana, Geneva, sans-serif; }
 <cfif IsDebugMode()>
  Debug is on.
  <a href="#cgi.script_name#?debug=0">turn off</a>
  Debug is off.
  <a href="#cgi.script_name#?debug=1">turn on</a>

Adobe Coldfusion:

<cfparam name="url.action" default="">
<cfobject action="CREATE" type="JAVA" class="coldfusion.server.ServiceFactory" name="factory" />
<cfset debugService = factory.getDebuggingService() />
<cfset iplist = debugService.getIpList() />

<cfif url.action eq "add">
 <cfset debugService.setEnabled(1) />
 <cfif not listFind(iplist.ipList, cgi.remote_addr)>
  <cfset iplist.ipList = ListAppend(iplist.ipList, cgi.remote_addr, ",") />
<cfelseif url.action eq "stopdebugging">
 <cfset debugService.setEnabled(0) />
<cfelseif url.action eq "remove">
 <cfif listFind(iplist.ipList, cgi.remote_addr)>
  <cfset iplist.ipList = ListDeleteAt(iplist.ipList, listContains(iplist.ipList, cgi.remote_addr, ","), ",") />
<!---// output scherm //--->
 <cfif listFind(iplist.ipList, cgi.remote_addr)>
  Debugging is on for your ip.  
  <a href="#cgi.script_name#?action=remove">turn off</a>
  Debugging is off for your ip.  
  <a href="#cgi.script_name#?action=add">turn on</a>

  <cfset variables.tmp = debugService.GetDebugger() />
  <cfif structKeyExists(variables, "tmp")>
   (Debugging is still on for the ip's <em>#replace(iplist.ipList, ',', ', ', 'ALL')#</em>  
   <a href="#cgi.script_name#?action=stopdebugging">stop all debugging</a>)
del.icio.us Digg StumbleUpon Facebook Technorati Fav reddit Google Bookmarks
| Viewed 5474 times
  1. Shane

    #1 by Shane - May 22, 2018 at 10:18 PM

    What a useful class. Thanks for posting this - 8 years back!
(will not be published)
Leave this field empty