Skip to content

Logback requires a lot of configuration to work with SubstrateVM #807

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

Closed
sdeleuze opened this issue Nov 15, 2018 · 5 comments
Closed

Logback requires a lot of configuration to work with SubstrateVM #807

sdeleuze opened this issue Nov 15, 2018 · 5 comments
Assignees

Comments

@sdeleuze
Copy link
Collaborator

Logback configuration does not work with SubstrateVM, see this repro project.

In regular JVM
-2018-11-15 15:34:12.276 -DEBUG -  --- [           main] ROOT                                     : Message 1
-2018-11-15 15:34:12.281 - WARN -  --- [           main] ROOT                                     : Message 2

As GraalVM native image

%PARSER_ERROR[clr] %PARSER_ERROR[clr] %PARSER_ERROR[clr] %PARSER_ERROR[clr] %PARSER_ERROR[clr] %PARSER_ERROR[clr] %PARSER_ERROR[clr] %PARSER_ERROR[m]%PARSER_ERROR[n]%PARSER_ERROR[clr] %PARSER_ERROR[clr] %PARSER_ERROR[clr] %PARSER_ERROR[clr] %PARSER_ERROR[clr] %PARSER_ERROR[clr] %PARSER_ERROR[clr] %PARSER_ERROR[m]%PARSER_ERROR[n]

Tested with GraalVM 1.0.0 RC9

@dsyer
Copy link

dsyer commented Nov 16, 2018

It works for me with this JSON in -H:ReflectionConfigurationFiles:

[
    {
        "name" : "com.sample.ColorConverter",
        "allPublicConstructors": true,
        "allPublicMethods": true,
        "allDeclaredMethods": true
    },
    {
		"name": "ch.qos.logback.classic.pattern.DateConverter",
		"allDeclaredConstructors": true
	},
	{
		"name": "ch.qos.logback.classic.pattern.MessageConverter",
		"allDeclaredConstructors": true
	},
 	{
 		"name": "ch.qos.logback.classic.pattern.ThrowableProxyConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.NopThrowableInformationConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.ContextNameConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.BoldYellowCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.LoggerConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.ReplacingCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.BoldBlueCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.CyanCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.RedCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.WhiteCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.PropertyConverter",
 		"allDeclaredConstructors": true
 	},
    {
 		"name": "ch.qos.logback.classic.pattern.ExtendedThrowableProxyConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.RootCauseFirstThrowableProxyConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.MethodOfCallerConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.LevelConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.IdentityCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.BoldWhiteCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.MarkerConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.BoldCyanCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.BoldMagentaCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.RelativeTimeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.MagentaCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.ClassOfCallerConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.LineOfCallerConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.FileOfCallerConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.BoldGreenCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.LocalSequenceNumberConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.YellowCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.ExtendedThrowableProxyConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.color.HighlightingCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.GrayCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.MDCConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.ClassOfCallerConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.BoldRedCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.GreenCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.core.pattern.color.BlackCompositeConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.ThreadConverter",
 		"allDeclaredConstructors": true
 	},
 	{
 		"name": "ch.qos.logback.classic.pattern.LineSeparatorConverter",
 		"allDeclaredConstructors": true
 	}
]

@sdeleuze
Copy link
Collaborator Author

Indeed, I have updated the repro project accordingly.

That said, could GraalVM team have a look to see if there is something that could be improved in GraalVM reflection support to avoid this huge configuration for a basic need?

@cstancu cstancu self-assigned this Nov 20, 2018
@sdeleuze sdeleuze changed the title Logback configuration does not work with SubstrateVM Logback requires a lot of configuration to work with SubstrateVM Nov 27, 2018
@rahulsom
Copy link

Any luck getting file appenders to work?

This is what I get.

error: Detected a FileDescriptor in the image heap. File descriptors opened during image generation are no longer open at image run time, and the files might not even be present anymore at image run time. The object was probably created by a class initializer and is reachable from a static field. By default, all class initialization is done during native image building.You can manually delay class initialization to image run time by using the option --delay-class-initialization-to-runtime=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Detailed message:
Error: Detected a FileDescriptor in the image heap. File descriptors opened during image generation are no longer open at image run time, and the files might not even be present anymore at image run time. The object was probably created by a class initializer and is reachable from a static field. By default, all class initialization is done during native image building.You can manually delay class initialization to image run time by using the option --delay-class-initialization-to-runtime=<class-name>. Or you can write your own initialization methods and call them explicitly from your main entry point.
Trace:  object java.io.FileOutputStream
        object ch.qos.logback.core.recovery.ResilientFileOutputStream
        object ch.qos.logback.core.rolling.RollingFileAppender
        object java.lang.Object[]
        object java.util.concurrent.CopyOnWriteArrayList
        object ch.qos.logback.core.util.COWArrayList
        object ch.qos.logback.core.spi.AppenderAttachableImpl
        object ch.qos.logback.classic.Logger
        object ch.qos.logback.classic.LoggerContext
        object org.slf4j.impl.StaticLoggerBinder
        field org.slf4j.impl.StaticLoggerBinder.SINGLETON

@cstancu
Copy link
Member

cstancu commented Mar 10, 2019

@sdeleuze the Assisted Configuration of Native Image Builds should make it easier to discover the reflectivelly accessed elements. Reflection configuration is still required for reflective access and we don't plan to change that. Enabling reflective access for all elements, without any config, although possible, would increase the size of the generated image due to the needed metadata. I tried your repo and your example works as expected. I am closing this issue as not a bug.

@cstancu cstancu closed this as completed Mar 10, 2019
@cstancu
Copy link
Member

cstancu commented Mar 10, 2019

@rahulsom did you try using --delay-class-initialization-to-runtime=... as mentioned in the error message? You can read more about class initialization on native-image. Please open another issue and provide a reproducible example if you still have problems.

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

4 participants