log4j2 problems with fatjar

6,122 views
Skip to first unread message

Asher Tarnopolski

unread,
Dec 8, 2014, 11:11:56 AM12/8/14
to ve...@googlegroups.com
hi folks, 

i'm not sure if this is related to vertx and not to log4j2, but maybe someone here has seen such behavior and has a solution.
i use log4j2 with vertx. the log4j2.xml is linked through java property passed to jvm on startup, both when i run the app from within
intellij and when i try to deploy a fatjar. (gradle built)
while in intellij all works as expected, i can't make this work from a fatjar.
the logger fails to be initialized properly:


java -Dvertx.logger-delegate-factory-class-name=atarno.logging.Log4j2LogDelegateFactory -Dlog4j.configurationFile=/home/atarno/log4j2.xml -jar /home/atarno/fat.jar

...

ERROR StatusLogger Unrecognized format specifier [d]
ERROR
StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR
StatusLogger Unrecognized format specifier [thread]
ERROR
StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR
StatusLogger Unrecognized format specifier [level]
ERROR
StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR
StatusLogger Unrecognized format specifier [logger]
ERROR
StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR
StatusLogger Unrecognized format specifier [msg]
ERROR
StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR
StatusLogger Unrecognized format specifier [n]
ERROR
StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
ERROR
StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
ERROR
StatusLogger Unrecognized format specifier [d]
ERROR
StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR
StatusLogger Unrecognized format specifier [thread]
ERROR
StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR
StatusLogger Unrecognized format specifier [level]
ERROR
StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR
StatusLogger Unrecognized format specifier [logger]
ERROR
StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR
StatusLogger Unrecognized format specifier [msg]
ERROR
StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR
StatusLogger Unrecognized format specifier [n]
ERROR
StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.


i have no idea where those [thread] come from, since the errors are the same even when i'm trying to use the simplest log4j2.xml config like this:

<?xml version="1.0" encoding="UTF-8" ?>
<Configuration status="WARN" monitorInterval="86400">
    <Appenders>
        <Console name="console-log" target="SYSTEM_OUT">
            <PatternLayout
                    pattern="%msg"/>
        </Console>
    </Appenders>
    <Loggers> 
        <Root level="info" additivity="false">
            <AppenderRef ref="console-log"/>
        </Root>
    </Loggers>
</Configuration>

thanks

Alexander Lehmann

unread,
Dec 8, 2014, 3:30:48 PM12/8/14
to ve...@googlegroups.com
could you put up a minimal project that shows the issue? since there is no log4j2 implementation included in vert.x currently, I can only guess what you are using and so the issue may not show in an alternate implementation.

The vert.x fatjar start code has changed a bit in the current version, so please make sure you are using 2.1.5

Asher Tarnopolski

unread,
Dec 8, 2014, 3:44:14 PM12/8/14
to ve...@googlegroups.com
thanks alexander, actually i forgot to mention that my post is about v3.
i'll try to put up a minimal project tomorrow.
which really reminds me of the problem i have.
when all jars are copied to the same folder and vertx is triggered be means of "io.vertx...Starter run verticle.class..." all is good.
when the entire project is packed in a fat jar and i try to "java -jar" - the logger is dead. it seems like it can't allocate its own classes or something.

Weston Price

unread,
Dec 8, 2014, 3:45:26 PM12/8/14
to ve...@googlegroups.com
Also, you may want to try:

java -Dvertx.logger-delegate-factory-class-name=atarno.logging.Log4j2LogDelegateFactory -Dlog4j.configurationFile=file:///home/atarno/log4j2.xml -jar /home/atarno/fat.jar

Note, the addition of 'file:///' I believe this was required on older versions of log4j to enable it to find your config file. I'm guess it works in IntelliJ because it's on the class path. 

Give that a shot. 

Asher Tarnopolski

unread,
Dec 8, 2014, 5:27:56 PM12/8/14
to ve...@googlegroups.com

unfortunately it doesn't help.

Asher Tarnopolski

unread,
Dec 8, 2014, 5:54:09 PM12/8/14
to ve...@googlegroups.com
ok guys, false alarm.  
i removed my projects dependencies from gradle one by one and figured out that the problem happens because of 
compile 'org.apache.logging.log4j:log4j-flume-ng:2.1'
this is not a vertx issue.
thanks everybody for your time.

Weston Price

unread,
Dec 8, 2014, 7:59:07 PM12/8/14
to ve...@googlegroups.com
Awesome, an 'easy' solution. We like those :-)
Reply all
Reply to author
Forward
0 new messages