I am making a simple Grails plugin that will act as a central configuration for journaling various companies. The general idea is that you simply add the plugin to your project and it will inject various applications into the root log. I test this first with the Graylog2 application (which works if I just configure it in Config.groovy). This is the code I tried (in init () from BootStrap.groovy [which starts when it starts]:
def rL = Logger.rootLogger
def layout = new PatternLayout(conversionPattern: '%d{dd-MM-yyyy HH:mm:ss,SSS} %5p %c{1} - %m%n')
Appender appender = new org.graylog2.log.GelfAppender(
name:"gelf",
graylogHost:"graylog2.ourcompany.com",
extractStacktrace: true,
addExtendedInformation: true,
facility: "gelf-java",
threshold: org.apache.log4j.Level.INFO,
additionalFields: "{'runtime': 'grails', 'environment': 'dev', 'transport': 'gelf-java'}",
layout: layout
)
rL.addAppender(appender)
The application is correctly created and attached to the root log, here it is derived from rL.getAllAppenders (). toList (). each {print it.toString ()}:
org.codehaus.groovy.grails.plugins.log4j.appenders.GrailsConsoleAppender@7a054197
org.graylog2.log.GelfAppender@6f155f16
, , Appender , ( ), Graylog2 ( Wireshark, ). , Config.groovy ; , , .