Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

log4j2-gelf "ERROR StatusLogger appenders contains an invalid element or attribute "GELF" "

just started to get into Graylog2 and wanted to log some Java-Applications via GELF Input. Therefore I used the library log4j2 and added the graylog2-gelfclient. All dependencies are satisfied and the programm is running. But the initialisation of my Logmanager is throwing the following error:

ERROR StatusLogger appenders contains an invalid element or attribute "GELF"

My code is just logging an error to the logger:

static final Logger logger = LogManager.getLogger(Application.class); 
    public static void main(String[] args) {
        logger.error("This is an error log entry");
    }
}

and my log4j2.xml file is configured to use GELF and the GelfAppender:

<configuration status="OFF">
    <appenders>
        <GELF name="gelfAppender" server="192.168.1.1" port="12201" hostName="myhost"/>
    </appenders>
    <loggers>
        <root level="info">
            <appender-ref ref="gelfAppender"/>
        </root>
    </loggers>
</configuration>

Is anyone familiar with this problem? Thanks for any help.

like image 807
Felix Avatar asked Oct 21 '14 15:10

Felix


1 Answers

It sounds like there is a problem with either the dependencies, or log4j has some other trouble loading or initializing the GELF appender plugin. It may be a good idea to mention your exact dependencies, both for log4j2 and log4j2-gelf. (Otherwise we have to guess...)

Furthermore, try setting status output to trace with

<configuration status="trace" ...

and take a look at the log4j internal log messages that are shown on the console. This should give you some insight into what is going wrong. Hopefully there is a clear ERROR-level message in that output that tells us what the problem is.

like image 111
Remko Popma Avatar answered Sep 21 '22 14:09

Remko Popma