Search code examples
grailsprofiler

How to append grails logging using profiler into custom appender(log file)?


Using grails profiler plugin, I want to append logging into separate file only for profiler.


Solution

  • You should be able to create an appender and then set the appropriate logger (looks to be com.linkedin.grails) to append to it with additivity set to false.

    grails 3.x:

    appender("PROFILER", FileAppender) {
        file = "profiler.log"
        encoder(PatternLayoutEncoder) {
            pattern = "%level %logger - %msg%n"
       }
    }
    
    logger("com.linkedin.grails", DEBUG, ["PROFILER"], false) // false here is for additivity
    

    grails before 3:

    file name: 'profiler', file: 'profiler.log', layout: pattern(conversionPattern: '%d{[yyyy-MM-dd HH:mm:ss.SSS]} [%t] %-5p: %c %x - %m%n')
    
    debug profiler: [
                "com.linkedin.grails"
    ], additivity: false