You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2016/11/02 07:38:58 UTC

[jira] [Comment Edited] (LOG4J2-1659) Facilitate shading Log4j into an application's uber jar

    [ https://issues.apache.org/jira/browse/LOG4J2-1659?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15628072#comment-15628072 ] 

Gary Gregory edited comment on LOG4J2-1659 at 11/2/16 7:38 AM:
---------------------------------------------------------------

To make matters more hacky, I tried to replace the log4j-web DAT file with log4j-core's DAT file in my uber jar since by default we log to the console. I got an error about the dat file's checksum not matching the manifest. If I want to go with that hack, the shading needs to remove all the checksum info from the manifests. Bleh. I might as well help toward a real solution which is properly merging DAT files.
{noformat}
Caused by: java.lang.SecurityException: SHA-256 digest error for META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat
        at sun.security.util.ManifestEntryVerifier.verify(ManifestEntryVerifier.java:230)
        at java.util.jar.JarVerifier.processEntry(JarVerifier.java:252)
        at java.util.jar.JarVerifier.update(JarVerifier.java:239)
        at java.util.jar.JarVerifier$VerifierStream.read(JarVerifier.java:493)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:257)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:297)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:356)
        at java.io.DataInputStream.readFully(DataInputStream.java:206)
        at java.io.DataInputStream.readUTF(DataInputStream.java:620)
        at java.io.DataInputStream.readUTF(DataInputStream.java:575)
        at org.apache.logging.log4j.core.config.plugins.processor.PluginCache.loadCacheFiles(PluginCache.java:109)
        at org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.decodeCacheFiles(PluginRegistry.java:166)
        at org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.loadFromMainClassLoader(PluginRegistry.java:119)
        at org.apache.logging.log4j.core.config.plugins.util.PluginManager.collectPlugins(PluginManager.java:132)
        at org.apache.logging.log4j.core.pattern.PatternParser.<init>(PatternParser.java:131)
        at org.apache.logging.log4j.core.pattern.PatternParser.<init>(PatternParser.java:112)
        at org.apache.logging.log4j.core.layout.PatternLayout.createPatternParser(PatternLayout.java:209)
        at org.apache.logging.log4j.core.layout.PatternLayout.createSerializer(PatternLayout.java:123)
        ... 32 more
{noformat}


was (Author: garydgregory):
To make matter more hacky, I tried to replace the log4j-web DAT file with log4j-core's DAT file since by default we log to the console and I got an error about the dat file's checksum not matching the manifest. If I want to go with that hack, the shading needs to remove all the checksum info from the manifests. Bleh. I might as well help toward a real solution which is properly merging DAT files.

> Facilitate shading Log4j into an application's uber jar
> -------------------------------------------------------
>
>                 Key: LOG4J2-1659
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1659
>             Project: Log4j 2
>          Issue Type: Improvement
>            Reporter: Gary Gregory
>
> Facilitate shading Log4j into an application's uber jar.
> I have a use case where I create an Uber jar for a proprietary JDBC driver and all of its dependencies, which includes Log4j (now) 2.7.
> The result is a big fat jar that gets deployed in JBoss Wildfly 9.
> When the server starts up, logging is all messed up:
> {noformat}
> 00:32:06,955 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry log4j-api-2.7.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,960 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry log4j-core-2.7.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,961 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry log4j-iostreams-2.7.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,961 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry icu4j-57.1.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,962 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry icu4j-charset-57.1.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,962 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry log4j-jcl-2.7.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,963 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry commons-logging-1.2.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,963 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry log4j-jmx-gui-2.7.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,963 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry log4j-nosql-2.7.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,964 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry log4j-taglib-2.7.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,964 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry log4j-web-2.7.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,964 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry commons-dbcp2-2.1.1.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,965 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry commons-pool2-2.4.2.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,965 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry jansi-1.13.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,965 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry jcommander-1.48.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:06,966 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-5)  WFLYSRV0059: Class Path entry log4j-1.2-api-2.7.jar in /content/dv-jdbc-3.1.201610281922-all.jar  does not point to a valid jar for a Class-Path reference.
> 00:32:07,435 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized format specifier [d]
> 00:32:07,442 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
> 00:32:07,476 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized format specifier [thread]
> 00:32:07,479 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
> 00:32:07,492 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized format specifier [level]
> 00:32:07,538 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
> 00:32:07,556 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized format specifier [logger]
> 00:32:07,558 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
> 00:32:07,558 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized format specifier [msg]
> 00:32:07,559 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
> 00:32:07,560 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized format specifier [n]
> 00:32:07,561 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
> 00:32:07,593 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
> 00:32:07,595 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized format specifier [d]
> 00:32:07,595 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
> 00:32:07,596 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized format specifier [thread]
> 00:32:07,597 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
> 00:32:07,597 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized format specifier [level]
> 00:32:07,598 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
> 00:32:07,598 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized format specifier [logger]
> 00:32:07,599 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
> 00:32:07,600 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized format specifier [msg]
> 00:32:07,600 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
> 00:32:07,601 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized format specifier [n]
> 00:32:07,602 ERROR [stderr] (MSC service thread 1-2)  ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
> {noformat}
> What to do? It looks like the uber jar picks up the last plugin DAT file (log4j-web).
> Unfortunately, https://github.com/edwgiz/maven-shaded-log4j-transformer does not work or I could not get it to work I should say.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org