In my ColdSpring config I have:
<bean id="AwesomeService" class="com.sweet.AwesomeService">
<property name="log">
<ref bean="logFactory"/>
</property>
</bean>
Then in AwesomeService I have:
<cffunction name="setLog" access="public" output="false"
returntype="void">
<cfargument name="Log" type="MachII.logging.LogFactory"
required="true" />
<cfset variables.Log = arguments.Log />
</cffunction>
<cffunction name="getLog" access="public" output="false"
returntype="MachII.logging.LogFactory">
<cfreturn variables.Log />
</cffunction>
I am a little confused on the intended usage after this point. I am
assuming that I can then add logging using this service in various parts
of the application, but I am not having much luck. For instance, I
tried to do:
<cfset getLog().getLog("MachIILog[CFLog as
well]").info("AwesomeService-logging","Doing some awesome stuff.") />
That doesn't generate any errors, but I can find no evidence that it is
doing anything at all. I know I am missing a critical key here, but
just having stumbled across what that is yet. Does anyone have any
examples? Additionally, how does this tie in with the Logging page in
the dashboard. In addition to turning logging on/off, will I be able to
view logging there as well?
Thanks in advance,
~Dave
Can you show me how you are setting up your logFactory bean def? If you
are creating your own logFactory, it's not same one that the Mach-II
instance is using.
Also, if you want your messages to show up, you need to configure some
loggers in the LogFactory as well. Check out this document to share the
Mach-II LogFactory in your model:
http://greatbiztoolsllc-trac.cvsdude.com/mach-ii/wiki/FAQUsingUtilityConnector
Also, you should be getting a log like this or use the factory methods
in CS to pass in a full Log object:
<cffunction name="setLog" access="public" returntype="void" output="false"
hint="Uses the log factory to create a log.">
<cfargument name="logFactory" type="MachII.logging.LogFactory" required="true" />
<!--- Get the channel name dynamically by using the CFC metadata --->
<cfset variables.log = arguments.logFactory.getLog(getMetadata(this).name) />
</cffunction>
<cffunction name="getLog" access="public" returntype="MachII.logging.Log" output="false"
hint="Gets the log.">
<cfreturn variables.log />
</cffunction>
When you get a log from the factory, the first argument is setting the
log channel (usually the dot path of the CFC). All log objects
"broadcast" the message to all registered loggers.
This is definitely some part of the doco that needs improvement.
As for seeing the messages, it depends on which one of the loggers you
have defined. If you are only using the Mach-II Logger, then any model
logging will show up in the logging output on the bottom of the page. If
you are using the CFLogger, then they will be in the CF log files (which
you'll have to use tail or other program to read). If you are using the
EmailLogger, they will send you an email message (recommend only using
this one when listening logging levels such as fatal or exception).
And yes, if you use the utility connector, you will be able to change
the logger settings from the dashboard.
.pjf
Dave Shuck said the following on 11/12/2008 8:02 AM:
Thanks for the clarifications.
~Dave