Just managed to solve the problem :)
First of all, I put the name of the package containing the GELF-appender into the log4j2.xml file.
<configuration status="OFF" packages="org.graylog2.log4j2"> <appenders> <GELF name="gelfAppender" server="192.168.1.1" port="12202" hostName="myhost"></GELF> </appenders> <loggers> <root level="info"> <AppenderRef ref="gelfAppender"/> </root> </loggers>
Then I got this error: "This code should never have turned into slf4j-api.jar"
I did not use Maven in the first place to get all the necessary packages. So I used Maven, and this gave me a hint that the imported slf4j-api.java files where not expected. If you download the official SLF4J distribution, be careful what files you import. Firstly, I imported java files from the "slf4j-api" folder - but this folder contains the "impl" folder, which caused the error that I mentioned above. Therefore, I imported sl4j-api-1.7.7.jar, which is also in the official distribution of SLF4J (this bank does not contain an "impl" package), and now it works fine.
Note. I received this message when starting the program:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html
source share