lusis/log4j-jsonevent-layout — pull request #5 by StFS (2013-02-08 15:37:29+00:00)
Title: Making location info optional improves performance.

Hi.

I have made the location information in the log messages optional after finding a bug in Grails which rendered them completely useless (the location was always inside a SLF4J class - see: http://jira.grails.org/browse/GRAILS-9826). Until I get that fixed I wanted to turn off the generation of location information and found out that this couldn't be done with the current version of your layout.

I've added a constructor, getter and setter for whether location information should be included in the log message. If not, the location information is not generated at all which saves quite some time.

I also added unit tests for this and to measure the performance difference between having the location information or not. The performance difference is quite significant. The following is the result of a typical run where I output 100.000 warn messages:
First Measurement (locationInfo: true): 4553
Second Measurement (locationInfo: false): 729

The measurement method is marked as a @Test for convenience but I also put a @Ignore on it for now. This does generate a warning message so it could be done better but unfortunately I don't have time to figure out what the right way to do this is now but I wanted to include this method so you could see that there is in fact a benefit of being able to exclude this information.