In the ColdFusion Administrator you can configure the logging behaviour to some extend. Where the ColdFusion logfiles are written, whether to log all email messages, long running pages etc. But you can not change the columns or masks for date formatting there, which is unfortunate because the native date mask for the logging is rather ambiguous. On my Dutch locale server the date “04/07/08″ should mean July 4th, but the log entry was written April 7th.

Fortunately, though not exposed in the ColdFusion Administrator, we can change the columns and patterns of the logfile directly in neo-logging.xml. By default, it defines the following pattern for the logging:

<var name="pattern">
    <string>"%p","%t",%d{"MM/dd/yy","HH:mm:ss"},%a,"%m%x"%n</string>
</var>

If we change the date mask in this pattern to something unambiguous, like the format defined in ISO 8601, we can now process our logfiles using tools written for our own locale:

<var name="pattern">
    <string>"%p","%t",%d{"yyyy-MM-dd","HH:mm:ss"},%a,"%m%x"%n</string>
</var>

Obviously you can change even more in the logging if you want, but if you start swapping / removing columns you may discover that the Logfile Reader that is part of the Adobe Extensions for Eclipse won’t work anymore. And like any change to a configuration file, make sure you have a backup before you start and make sure you restart the server once you have made the changes to detect any errors immediately instead of when the server won’t start at 3 AM.

Those who deploy ColdFusion on top of JRun may have noticed that the date mask in the JRun logfiles is even worse. Luckily here too we can configure the mask in a configuration file, jrun.xml:

<attribute name="format">{date yyyy-MM-dd HH:mm:ss} {log.message}{log.exception}</attribute>

The same warnings apply as with the ColdFusion log files.

4 Comments

  1. PaulH says:

    yeah we hit this issue on a thai locale server (win 2003). made a huge mess of our logs.

    the thai locale also blew up some image uploading & manipulation bits that used EXIF datetimes (if the logs hadn’t been messed up we’d probably still be tracking this down ;-).

    thanks for the detective work.

  2. Doug says:

    The pattern interests me.

    “%p”,”%t”,%d{”MM/dd/yy”,”HH:mm:ss”},%a,”%m%x”%n

    Where are the percent prefixed “variables” defined? Can we alter/add/remove those on our own? I can’t seem to find what these things reference.

  3. Jochem says:

    The variables are defined somewhere deep in the JRun / ColdFusion sourcecode. I don’t think we can alter or add them, but of course you can remove them.

  4. todoslot says:

    The post is great… What i am looking for…
    good job! coche slot