Logback support in Quarkus - quarkus

I have tried to add logback in Quarkus, but later realised Quarkus does not support logback. If I am wrong, May I know how logback can be configured in Quarkus with an example. Thanks in advance.

No, in Quarkus, we standardized on using JBoss Logging for the logging.
And AFAIK we don't even have a bridge from logback to JBoss Logging as for some other logging components so you can't even use the Logback API in your application.

In currrent version 1.6.0.final of Quarkus You can use one of the Logging API's below
JDK java.util.logging
JBoss Logging
SLF4J
Apache Commons Logging
https://quarkus.io/guides/logging

There is a Quarkus extension which enables logback: https://quarkiverse.github.io/quarkiverse-docs/quarkus-logging-logback/dev/index.html
However there are some restrictions, mostly due to internal Quarkus specifics:
Your Quarkus version should match version used for 'quarkus-logging-logback' extension build
If you want to use own appenders/listeners in 'logback.xml' - you should put them in separate library and include them in your project through library

Related

Why does spring-boot-starter-logging require a dependency on log4-to-slf4j

I have a Spring Boot 2.6.3 project that uses spring-boot-starter. When I run the dependecy:tree goal in maven, I see that spring-boot-starter-logging depends on both logback and (indirectly) log4j. Why does spring-boot-starter-logging require a dependency on log4-to-slf4j?
Spring Boot has bindings for all major logging frameworks. With a single configuration you can concentrate logs sent through SLF4J, Log4j 2.x API or java.util.logging.
Therefore the spring-boot-starter-logging provides:
a binding for SLF4J (logback-classic),
an implementation of the Log4j 2.x API (log4j-to-slf4j). Remark that this is not the standard Log4j 2.x Core implementation.
a handler for java.util.logging (jul-to-slf4j).
Remark that spring-boot-starter-log4j2 does the same thing and redirects the frameworks above to Log4j 2.x Core.
The big absent in this picture is Jakarta Commons Logging, which is only able to bind to java.util.logging (hence not directly to neither Logback nor Log4j 2.x Core). However spring-core depends on spring-jcl, which binds JCL directly to SLF4J or the Log4j 2.x API and can entirely replace the original JCL.
A fifth API (Log4j 1.x) was supported in Spring Boot 1.x.

Which dependency should be used to integrate Apache Camel with Spring Boot

Apache Camel provides two ways to integrate with Spring Boot:
camel-spring-boot
camel-spring-boot-starter
When I look at the starter then I see that it only includes camel-spring-boot and spring-boot-starter. What is the difference then and what are the advantages of using starter?
At the moment of writing this answer, camel-spring-boot is only supported from Camel 2.15 and camel-spring-boot-starter only from Camel 2.17, which is important considering the current version that your project is using.
Then the major difference between these two dependencies, lies in the "opinionated" auto-configuration provided by the starter.
camel-spring-boot, should be used if you want just to include a jar to make your camel routes auto-discovered by spring boot, this also gives you the freedom to update this dependency regardless of your spring-boot version.
camel-spring-boot-starter, (recommended way to go) should be used if you want a collection of dependencies (including camel-spring-boot) that provides the best developer/user experience, due to the fact of customizable properties, additional libraries, and default configuration for the camel library. Check the reference documentation for the starter: https://camel.apache.org/components/latest/spring-boot.html#_spring_boot_auto_configuration
Summary
Use camel-spring-boot, if you want a vanilla jar to use camel with spring boot
Use camel-spring-boot-starter, if you want an automatic-configured component to start to develop with.
You should always use the camel-xxx-starter dependencies, as these are the Camel components that is support with Spring Boot. Also as mentioned they provide auto configuration and some of them additional capabilities.
If there is no camel-xxx-starter component then its because its not supported on Spring Boot with Camel.
See more at: https://github.com/apache/camel/tree/master/platforms/spring-boot/components-starter#camel-component-starters

Project uses Log4j2 but dependency uses Log4j

We have a new project which we're writing using Spring Boot in which we're using Log4j2 for our logging.
The problem is that we need to use an legacy library, which we own but we can't change; several other systems use it and we can't increase our scope by changing all of them.
When our project runs, it logs just fine using Log4j2, but when we make calls to the legacy library, it makes Log4j calls which throw exceptions.
Is there a way to, in our new application which uses log4j2, handle the old log4j calls?
Update
Our legacy JAR contains several JARs in an internal lib folder including:
log4j-1.2.6.jar
Our project is a Spring Boot project and we've included the dependency:
org.springframework.boot:spring-boot-starter-log4j2
The log4j JARS that I see on the projects classpath are:
spring-boot-starter-log4j2--1.5.9.RELEASE.jar
log4j-slf4-impl-2.7.jar
log4j-api-2.7.jar
log4j-core-2.7.jar
Have you tried the log4j-1.2-api adapter? Use this together with the log4j-api and log4j-core dependencies. The adapter lets applications use the Log4j 1.2 API, but routes these calls to the log4j2 implementation. See the which jars question in the FAQ.
If the application uses internal Log4j 1.2 classes this may not work but for plain logging it’s a drop-in replacement of the log4j-1.2.x jar.
Note that the legacy log4j-1.2.x jar should be removed from the classpath for this to work.
Update: if the legacy jar contains the Log4j 1.2.x jar and this causes the Log4j 1.2.x jar to be added to the classpath, the results are undefined.
I believe you have little choice but to create a custom version of this legacy jar without the Log4j 1.2.x jar. Other systems in your organization can continue to use the original legacy jar with the embedded Log4j 1.2.x jar, until they also want to migrate to Log4j2.
Your new version of the legacy jar (without embedded Log4j 1.2.x jar) may become the pathway to migrating to Log4j2 for all other systems in your organization.

Log4j conflicts with commons logging in a Spring RESTful integration on tomcat 6

I am trying to integrate Spring RESTful service in my project which already uses log4j. Log4j is conflicting with commonslogging and not initializing the service. I am using commons logging to compile spring jar.
If your using Maven try
<scope> provided</scope> for log4j transitive dependencies.
Issue has been resolved by including log4j.xml in my classes folder.
With all research on this topic, I come to know that jar conflict issue is with Webspehere not with Tomcat.

using slf4j to log in spring when I can't get rid of commons-logging

I'm using some a component other than Spring that has a commons-logging dependency.
So, excluding commons-logging from the spring dependency doesn't get rid of it, and so the instructions here aren't helping. Is there some more declarative way to push Spring 3.0.5 to talk to slf4j?
I had an issue on Tomcat 6 where Commons Logging wouldn't play nice with SLF4J which got dragged in from Hibernate. We had configured Commons Logging to go to Log4J anyway. After explicitly including "slf4j-log4j 1.6.1" and its "jcl-over-slf4j 1.6.1" component to take out Commons Logging, I still got errors from Commons Logging. The answer lied in this blog post: You explicitly include Commons Logging at version "99.0-does-not-exist". This includes an empty JAR, so that only the SLF4J code gets executed now.
If you are using Maven, please read the FAQ entry about excluding commons-logging.
Use the SLF4j bridge

Resources