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

logback-tyler sometimes produces Java Code that still relies on XML Parsers and Janino #873

Closed
DarkAtra opened this issue Oct 16, 2024 · 2 comments
Assignees

Comments

@DarkAtra
Copy link

DarkAtra commented Oct 16, 2024

The logback-tyler readme claims that:

Running TylerConfigurator does not require XML parsers and usually executes noticeably faster than JoranConfigurator, logback's XML configurator.

However, <include resource="logback-console-appender.xml"/> is translated to:

IncludeModel includeModel = new IncludeModel();
includeModel.setResource(subst("logback-console-appender.xml"));
IncludeModelHandler includeModelHandler = new IncludeModelHandler(context);
try {
    Model modelFromIncludedFile = includeModelHandler.buildModelFromIncludedFile(this, includeModel);
    processModelFromIncludedFile(modelFromIncludedFile);
} catch(ModelHandlerException e) {
    addError("Failed to process IncludeModelHandler", e);
}

To me it seems like includeModelHandler.buildModelFromIncludedFile(this, includeModel) uses an XML parser internally and the referenced xml file is probably also allowed to use conditions which then also requires Janino (an issue with GraalMV).

Is there any way to configure logback-tyler so that it also resolves and translates included files?

Versions:

logback-classic: 1.5.11
logback-tyler: 0.9
@ceki
Copy link
Member

ceki commented Oct 19, 2024

@DarkAtra Thank you for this report.

I have modified the generated code to have an include() method the contents of which are very similar to the code you mention above.

Please note at translation time logback-tyler usually does not have access to the included file.

It follows that the code in include() method produced by logback-tyler falls back to invoking logback-classic's default configurator, i.e. JoranConfigurator which will invoke an XML parser in the process.

If you wish to avoid calling JoranConfigurator, then you can insert the contents of the included XML file into the containing file manually before performing the logback-tyler translation.

Also note that PropertiesConfigurator introduced in version 1.5.8, allows for setting logger levels via a properties file. The location of properties files can be specified as a file path as well a URL via HTTP or HTTPS protocols. Watching files and reconfiguration upon change is also supported. Logback-tyler supports PropertiesConfigurator.

@DarkAtra
Copy link
Author

Ok, i just wanted to make sure that this is expected behaviour. I will merge our XML configs and run them through logback-tyler again

@ceki ceki self-assigned this Oct 25, 2024
@ceki ceki added the NOT A BUG label Oct 25, 2024
@ceki ceki closed this as completed Oct 25, 2024
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