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

PatternLayoutBase custom converter classloading trouble in OSGi #803

Open
enapps-enorman opened this issue Apr 13, 2024 · 0 comments
Open

Comments

@enapps-enorman
Copy link

The values in the PatternLayoutBase defaultConverterMap and instanceConverterMap are class names. The ch.qos.logback.core.pattern.parser.Compiler class attempts to load the class for those class names with the assumption that those classes are visible to the classloader that loaded the logback-core classes.

Unfortunately, in an OSGi environment, my custom converter classes from a custom OSGi bundle are not visible to the classloader of the logback-core bundle. This scenario results in a "Failed to instantiate converter class" error and it doesn't work as expected.

My proposal is to allow the the values of the defaultConverterMap and instanceConverterMap to alternately be supplied as a Supplier function instead of a classname. The Supplier would not have the same class visibility problem.

Using a Supplier seems to be a technique that I see in other places in the logback codebase, so it seems like it should make sense to allow that for this scenario as well.

I will supply a PR with the proposed changes for your consideration

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

No branches or pull requests

1 participant