I’ve got a logging function (can’t use cflog) included in application.cfm and my .cfm pages can access this, but any components I use give me a “Variable LOGGER is undefined.” error.
application.cfm
<cfinclude template="logging.cfm">
logging.cfm
<cffunction name="logger" >
...
</cffunction>
Any ideas as to what I’m doing wrong?
because the way components work is that a component can’t see the “
variables” scope outside of itself, and when you<cfinclude>yourlogging.cfm, it’s including those functions into the page’s variable scope. in order for your component to call those functions, you might do this:and then in your
<cfcomponent>, you could callrequest.logger(whatever).But honestly, this feels backwards to me. Instead, why not a
Logger.cfcthat contains a function named “log”, and then when you want to log something, you just do: