Tapping into ColdFusion MX 6.1 Logging

H

howbizr

This isn't a question... but a record of my experience for anyone else
doing this. In my googling on this topic, I didn't find many answers,
so here's what I came up with.

I discovered... 6.1 has pretty old Log4J, v1.1.3. Thankfully, it's
open source, and very readily available, despite being an old version.
So that helps.

As far as I can tell, if you just want to use the old logger, and hope
that ColdFusion picks up your stuff, do something like this...

public static Category logger =
Category.getInstance(MyClass.class.getName());

if(logger.getChainedPriority().isGreaterOrEqual(Priority.DEBUG)) {
logger.debug("My debug message");
}

And if you want to interface with ColdFusion's logger directly
(tapping into cfusion-out.log), try this...

private static Logger logger = LoggerService.createDefaultLogger();

if(logger.isDebugEnabled()) {
logger.logDebug("My debug message");
logger.flush();
}

And I did find there's a logger.xml file out there, supposedly for
adding custom definition. I haven't had much success with it, but
here's the path for those that might be interested. This does vary
slightly per install, but it gives you a starting place.

C:\JRun4\servers\cfusion\cfusion-ear\cfusion-war\WEB-INF\cfusion
\logger.xml

Last thing, also undocumented, also very useful. You can enable more
debugging in the logs...
C:\JRun4\servers\cfusion\SERVER-INF\jrun.xml

Find this service and change "debugEnabled" to "true"...

<!--
================================================================== -->
<!-- This Service represents JRun's logging
facility -->
<!--
================================================================== -->
<service class="jrunx.logger.LoggerService" name="LoggerService">
<attribute name="format">{server.date} {log.level} {log.message}
{log.exception}</attribute>
<!-- You can modify format to suit your need. -->
<!-- EXAMPLE: <attribute name="format">{date MM/dd HH:mm:ss}
{log.message}{log.exception}</attribute> -->
<attribute name="errorEnabled">true</attribute>
<attribute name="warningEnabled">true</attribute>
<attribute name="infoEnabled">true</attribute>
<attribute name="debugEnabled">true</attribute>
<!-- You may also need to uncomment MetricsService if you want
metrics enabled -->
<attribute name="metricsEnabled">false</attribute>
<attribute name="metricsLogFrequency">60</attribute>
<attribute name="metricsFormat">Web threads (busy/total):
{jrpp.busyTh}/{jrpp.totalTh} Sessions: {sessions} Total
Memory={totalMemory} Free={freeMemory}</attribute>
<service class="jrunx.logger.ThreadedLogEventHandler"
name="ThreadedLogEventHandler">
<service class="jrunx.logger.ConsoleLogEventHandler"
name=":service=ConsoleLogEventHandler" />
<service class="jrunx.logger.FileLogEventHandler"
name="FileLogEventHandler">
<attribute name="filename">{jrun.rootdir}/logs/
{jrun.server.name}-event.log</attribute>
<attribute name="rotationSize">200k</attribute>
<attribute name="rotationFiles">3</attribute>
<!-- Use heading to specify an alternate log heading for
system event log. -->
<!-- EXAMPLE: <attribute name="heading"># Created by JRun on
{date MM/dd HH:mm:ss}</attribute> -->
<attribute name="closeDelay">5000</attribute>
<attribute name="deleteOnExit">false</attribute>
</service>
</service>
</service>


That's all she wrote folks... If I'm doing anything incorrectly,
please feel free to respond.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,156
Latest member
KetoBurnSupplement
Top