Logging in JSON format


#1

Hiya. I have a weird edge case problem I was hoping someone could help me with? I have a number of legacy apps on Lucee that use cflog tags for various reasons. I’m currently piping all logs (application and Lucee’s own logs) to Graylog by watching folders on disk and collecting the output, but the logs are annoying to parse in Graylog and we’re missing information. Ideal case, all the logs across the whole system would be in json format, written to disk in a known location, so that I can easily parse them in Graylog.

It looks like I can install something like log4j and add a log4j.properties file, but it’s not going to affect the cflog outputs. I can see people redirecting standard output to a udp stream, but for various reasons I can’t send logs over udp to graylog, they have to be on disk. It looks like in the lucee-web.xml.cfm there’s some extra options that might help me here, but I don’t understand how they work. I could also install something like Logbox, but I’d need to change all the current logging tags to make it work.

Any ideas?


#2

Thanks @yamikuronue! @isapir or @micstriit can one (or both) of you chime in on this one? I’m not sure there’s any other people who understand enough about how Lucee logs under the covers to answer this.


#3

I hope that you’re using Lucee 5, which already uses log4j as the underlying logging framework.

Please see the comments in the default lucee-web.xml circa line 180.

You can use XML (yuck!@#) which will be easier to setup and give you the information that you need at the expense of the weight of the XML format.

You can also specify a custom Pattern, or even a custom Class. I haven’t tried that myself, but see https://stackoverflow.com/questions/29387007/does-log4j-support-json-format for some possible options.


#4

P.S. Since we support XML format out of the box, I think that we should support JSON as well. Feel free to open a ticket for that in JIRA.


#5

the docs need updating for Lucee 5 then :slight_smile: