OiO.lk English java Filter console exceptions in Log4j from executed jar
java

Filter console exceptions in Log4j from executed jar


I am running a minecraft server and some addons keep spamming the console (and hence making it useless) with the following:
com.mojang.brigadier.exceptions.CommandSyntaxException

I want to get rid of this!
I need the correct log4j tag when running the jar and also the correct external log4j configuration file (xml only).

What I have tried:

I add the following parameters into executing the jar so it reads:

java -Dlog4j.debug -Dlog4j.configuration=file:///home/container/console.xml -Xms128M -XX:MaxRAMPercentage=95.0 -jar server.jar

Key here is:
-Dlog4j.configuration=file:///home/container/console.xml

I then put the following console.xml file into /home/container/ where it sits next to the server.jar file.

In the console.xml file, I made from: How to filter a specific exception from Log4j? the following configuration:

<Appenders>
    <Console name="console" target="System.out">
        <RegexFilter regex=".*" onMatch="DENY" onMismatch="NEUTRAL"/>
        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %-2p %c{1.} %x - %m%n"/> 
    </Console>
    <File name="logfile" filename="./app.log" append="true">
        <RegexFilter regex=".*" onMatch="DENY" onMismatch="NEUTRAL"/>
        <PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5p %c{-1} %X{userName} - %m%n"/> 
    </File>
</Appenders>

This however did nothing! And the Log4j debug did not help.



You need to sign in to view this answers

Exit mobile version