Legacy vs canonical Logback configuration
Asked Answered
M

1

6

When looking through Chapter 3 of the Logback manual, I've noticed that the configuration examples come in three varieties: Legacy, Canonical (1.3) and Tyler.

The manual stays pretty much silent about these options. So I wonder now what are these, and of their purpose and use cases.

I've only ever seen the Legacy option in practice and this is the one I use since it's the most succinct. The Canonical option adds a bit of boilerplate (<import>ing Java classes) and a weird <!DOCTYPE> declaration. (Note a note later on that the configuration syntax is so flexible that it's impossible to define a DTD schema for it. Why <!DOCTYPE> then?)

Mezereon answered 20/4 at 10:18 Comment(1)
i dont know logback, but Xml has a specific syntax which has been abused over the years to accommodate its use (see eg. Html)...parsers even have strict and lenient modes, so those options in logback could be related to this issueMathis
L
5

I tried to gather some informations:

and I'm guessing a bit. All those sources lead to this conclusion:

Logback initially introduced Joran, a configuration engine that could read XML files - the legacy format.

In Logback version 1.3, Joran was substantially changed. See 2021-07-28 Release of version 1.3.0-alpha6:

Joran, logback's configuration system, has been rewritten to use an internal representation model which can be processed separately. As a side effect, logback configuration scripts are now largely order-free.

This probably led to a change in the XML configurations and depending on the features you use in your logback configuration you might have to convert to the Canonical config when using 1.3.x or 1.4.x of Logback (of the two versions you need version 1.3.x if you want to work with Java EE and 1.4.x if you want to work with Jakarta EE, otherwise they should be equal).

Then Logback 1.5 came and supports configuration in code. To convert existing XML files into code, Tyler was released. See 2024-02-28 Release of logback-tyler version 0.1:

Logback-tyler translates logback-classic XML configuration files (logback.xml) into Java.


Disclaimer: As I think it is a pity that the differences are nowhere documented in a comprehensive way, I just tried to do this here, although I am not very deeply involved into Logback and not even using it regularly

Lusitania answered 29/4 at 17:25 Comment(1)
Sometimes knowledge is so close. I mean, even physically ;) Upvoted.Outermost

© 2022 - 2024 — McMap. All rights reserved.