Question about using logging

0 views
Skip to first unread message

Dave Shuck

unread,
Nov 12, 2008, 9:02:56 AM11/12/08
to mach-ii-for...@googlegroups.com
I am playing with the logging property new to 1.6 and have a some
questions on the intended usage and how this works in companion with the
dashboard. For starters, my config is set up like this:

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

Peter J. Farrell

unread,
Nov 12, 2008, 9:58:41 AM11/12/08
to mach-ii-for...@googlegroups.com
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:

Dave Shuck

unread,
Nov 12, 2008, 10:42:31 AM11/12/08
to mach-ii-for...@googlegroups.com
OK.... I think I get it. For some reason I was under the impression that
as I used the MachII logger that it would in essence save those log
events which I could then view later in the dashboard. To make matters
more confusing, the piece that I was testing it on was doing a <redirect
/> at the end of the event, so I never saw the piece that was being
logged at the bottom of the page.

Thanks for the clarifications.

~Dave

Reply all
Reply to author
Forward
0 new messages