Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log4j2 is broken with SubstrateVM #808

Closed
sdeleuze opened this issue Nov 15, 2018 · 1 comment
Closed

Log4j2 is broken with SubstrateVM #808

sdeleuze opened this issue Nov 15, 2018 · 1 comment
Assignees

Comments

@sdeleuze
Copy link
Collaborator

Log4j2 is broken with SubstrateVM, I have created a repro project.

In regular JVM

ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
16:07:03.828 [main] ERROR com.sample.App - Hello

It does not compile with native image:

error: unsupported features in 27 methods

Tested with GraalVM 1.0.0 RC10 latest snapshot (built from master)

@cstancu
Copy link
Member

cstancu commented Mar 8, 2019

With the latest master and the following config files:

Click to expand resource-config.json

{
  "resources":[
    {"pattern":"META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat"}, 
    {"pattern":"META-INF/services/org.apache.logging.log4j.spi.Provider"}, 
    {"pattern":"META-INF/services/org.apache.logging.log4j.util.PropertySource"}, 
    {"pattern":"org/slf4j/impl/StaticLoggerBinder.class"}
  ]
}

and

Click to expand reflect-config.json

[
  {
    "name":"java.io.ObjectInputStream",
    "allPublicMethods":true
  },
  {
    "name":"java.lang.String",
    "fields":[{"name":"value"}]
  },
  {
    "name":"org.apache.logging.log4j.core.config.json.JsonConfigurationFactory",
    "methods":[{ "name":"<init>", "parameterTypes":[] }]
  },
  {
    "name":"org.apache.logging.log4j.core.config.properties.PropertiesConfigurationFactory",
    "methods":[{ "name":"<init>", "parameterTypes":[] }]
  },
  {
    "name":"org.apache.logging.log4j.core.config.xml.XmlConfigurationFactory",
    "methods":[{ "name":"<init>", "parameterTypes":[] }]
  },
  {
    "name":"org.apache.logging.log4j.core.config.yaml.YamlConfigurationFactory",
    "methods":[{ "name":"<init>", "parameterTypes":[] }]
  },
  {
    "name":"org.apache.logging.log4j.core.lookup.JmxRuntimeInputArgumentsLookup",
    "methods":[{ "name":"<init>", "parameterTypes":[] }]
  },
  {
    "name":"org.apache.logging.log4j.core.lookup.JndiLookup",
    "methods":[{ "name":"<init>", "parameterTypes":[] }]
  },
  {
    "name":"org.apache.logging.log4j.core.pattern.DatePatternConverter",
    "allDeclaredMethods":true
  },
  {
    "name":"org.apache.logging.log4j.core.pattern.LevelPatternConverter",
    "allDeclaredMethods":true
  },
  {
    "name":"org.apache.logging.log4j.core.pattern.LineSeparatorPatternConverter",
    "allDeclaredMethods":true
  },
  {
    "name":"org.apache.logging.log4j.core.pattern.LoggerPatternConverter",
    "allDeclaredMethods":true
  },
  {
    "name":"org.apache.logging.log4j.core.pattern.MessagePatternConverter",
    "allDeclaredMethods":true
  },
  {
    "name":"org.apache.logging.log4j.core.pattern.ThreadNamePatternConverter",
    "allDeclaredMethods":true
  },
  {
    "name":"org.graalvm.compiler.nodes.FixedNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.FixedWithNextNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.ValueNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.calc.AddNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.calc.BinaryArithmeticNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.calc.BinaryNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.calc.FloatConvertNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.calc.FloatDivNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.calc.FloatingNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.calc.MulNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.calc.SqrtNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.calc.SubNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.calc.UnaryArithmeticNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.nodes.calc.UnaryNode",
    "allDeclaredFields":true
  },
  {
    "name":"org.graalvm.compiler.replacements.SnippetCounterNode",
    "allDeclaredFields":true
  },
  {
    "name":"sun.misc.Unsafe",
    "fields":[{"name":"theUnsafe"}]
  },
  {
    "name":"sun.reflect.Reflection",
    "methods":[{ "name":"getCallerClass", "parameterTypes":["int"] }]
  },
  {
    "name": "org.apache.logging.log4j.message.ReusableMessageFactory",
    "methods": [
      { "name": "<init>", "parameterTypes": [] }
    ]
  },
  {
    "name": "org.apache.logging.log4j.message.DefaultFlowMessageFactory",
    "methods": [
      { "name": "<init>", "parameterTypes": [] }
    ]
  }
]

you should be able to build the native image:

$ native-image -H:ReflectionConfigurationFiles=$PWD/config/reflect-config.json -H:ResourceConfigurationFiles=$PWD/config/resource-config.json --allow-incomplete-classpath -H:+ReportExceptionStackTraces --delay-class-initialization-to-runtime=org.apache.logging.log4j.core.pattern.JAnsiTextRenderer -cp target/log4j2-1.0-SNAPSHOT-jar-with-dependencies.jar com.sample.App

and get the expected output:

$ ./com.sample.app 
ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2
17:22:40.536 [main] ERROR com.sample.App - Hello

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants