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:

Railo:

<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" />
</cfif>
<!---are we in debug mode? --->
<cfoutput>
 <style type="text/css">
  * { font-size:12px; font-family:Verdana, Geneva, sans-serif; }
 </style>
 <cfif IsDebugMode()>
  Debug is on.
  <a href="#cgi.script_name#?debug=0">turn off</a>
 <cfelse>
  Debug is off.
  <a href="#cgi.script_name#?debug=1">turn on</a>
 </cfif>
</cfoutput>

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, ",") />
 </cfif>
<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, ","), ",") />
 </cfif>
</cfif>
<!---// output scherm //--->
<cfoutput>
 <cfif listFind(iplist.ipList, cgi.remote_addr)>
  Debugging is on for your ip.  
  <a href="#cgi.script_name#?action=remove">turn off</a>
 <cfelse>
  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>)
  </cfif>
 </cfif>
</cfoutput>
del.icio.us Digg StumbleUpon Facebook Technorati Fav reddit Google Bookmarks
| Viewed 4474 times
  1. Shane

    #1 by Shane - mei 22, 2018 at 22:18

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