logback icon indicating copy to clipboard operation
logback copied to clipboard

no-janino conditions

Open guai opened this issue 1 year ago • 4 comments

Feature request: pls make possible to write conditions without janino. it should allow to use conditions with native image for example.

I suggest something like a predicate-like interface that user would implement and use like so:

<if predicateClass="org.example.MyCondition">

or it could be a static method

guai avatar Dec 29 '23 07:12 guai

I'd also be very happy to get this feature. Without it, running spring boot native images force you to remove if conditions from spring-logback file. More info here

danparisi avatar Apr 05 '24 13:04 danparisi

Hey @ceki, i'm reaching out to you because you initally recommended filing an issue for this feature in this comment. We're currently in the process of migrating a few of our apps to native images and stumbled upon this issue. We're currently using Janino conditions to enable different types of sinks for our logs (kafka, tcp, file, console, ...) and also their format (JSON lines vs. formatted log lines). As you know, Janino is not compatible with GraalVM which makes this a blocker for our migration.

What do you think of the solution that guai proposed? Is this something that you would accept PRs for?

DarkAtra avatar Sep 09 '24 16:09 DarkAtra

@DarkAtra I have responded in the original issue. Please let me know what you think.

Also, the next version of logback-tyler will support PropertiesConfigurator (new in logback 1,5,8) which allows setting logger levels from a properties file.

ceki avatar Sep 09 '24 16:09 ceki

@DarkAtra I have responded in the original issue. Please let me know what you think.

Also, the next version of logback-tyler will support PropertiesConfigurator (new in logback 1,5,8) which allows setting logger levels from a properties file.

This looks very promising, i'll try with one of our projects. Ty for the quick response!

DarkAtra avatar Sep 09 '24 23:09 DarkAtra

@ceki and @guai, I think this can be closed ??

jhult avatar Oct 28 '25 15:10 jhult

Some links:

  • https://logback.qos.ch/codes.html#conditionAttributeDeprecation
  • https://logback.qos.ch/manual/configuration.html#conditional
  • https://github.com/qos-ch/logback/blob/v_1.5.20/logback-core/src/main/java/ch/qos/logback/core/boolex/PropertyEqualityCondition.java

jhult avatar Oct 28 '25 15:10 jhult

I think, yes

guai avatar Oct 28 '25 16:10 guai

@jhult @guai Indeed, version 1.5.20 allows writing conditions without janino. Conditional processing with Janino is still supported but will be removed in 2027.

ceki avatar Oct 28 '25 16:10 ceki