You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/02/14 08:12:44 UTC
(camel) branch camel-4.4.x updated: CAMEL-20418: camel-core - Log EIP should only use source line:name if enabled (#13112)
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.4.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.4.x by this push:
new 22721c623f2 CAMEL-20418: camel-core - Log EIP should only use source line:name if enabled (#13112)
22721c623f2 is described below
commit 22721c623f2e9ca04121609adc1cd67aae39050d
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Wed Feb 14 09:07:30 2024 +0100
CAMEL-20418: camel-core - Log EIP should only use source line:name if enabled (#13112)
---
.../src/main/docs/modules/eips/pages/log-eip.adoc | 11 +++++++----
.../src/main/java/org/apache/camel/reifier/LogReifier.java | 7 ++++++-
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/core/camel-core-engine/src/main/docs/modules/eips/pages/log-eip.adoc b/core/camel-core-engine/src/main/docs/modules/eips/pages/log-eip.adoc
index eb39dd5dfe4..7936d4e8f4b 100644
--- a/core/camel-core-engine/src/main/docs/modules/eips/pages/log-eip.adoc
+++ b/core/camel-core-engine/src/main/docs/modules/eips/pages/log-eip.adoc
@@ -92,7 +92,7 @@ from("file://target/files")
.to("bean:foo");
----
-In Spring DSL it is also easy to use log DSL as shown below:
+In XML DSL it is also easy to use log DSL as shown below:
[source,xml]
----
<route id="foo">
@@ -131,10 +131,10 @@ It is possible to reference an existing logger instance. For example:
=== Configuring logging name
-The log message will be logged at `INFO` level using the route id as the logger name.
-So for example if you have not assigned an id to the route, then Camel will use `route-1`, `route-2` as the logger name.
+The log message will be logged at `INFO` level using the route id as the logger name (or source name:line if source location is enabled, see TIP below).
+So for example, if you have not assigned an id to the route, then Camel will use `route-1`, `route-2` as the logger name.
-For example to use "fooRoute" as the route id, you can do:
+To use "fooRoute" as the route id, you can do:
[source,java]
----
@@ -154,6 +154,9 @@ And in XML:
</route>
----
+TIP: If you enable `sourceLocationEnabled=true` on `CamelContext` then Camel will use source file:line as logger name,
+instead of the route id. This is for example what `camel-jbang` do, to make it easy to see where in the source code the log is located.
+
==== Using custom logger from the Registry
If the Log EIP has not been configured with a specific logger to use,
diff --git a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/LogReifier.java b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/LogReifier.java
index a1744b48135..93dd053d2bb 100644
--- a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/LogReifier.java
+++ b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/LogReifier.java
@@ -76,7 +76,12 @@ public class LogReifier extends ProcessorReifier<LogDefinition> {
}
}
if (name == null) {
- name = getLineNumberLoggerName(definition);
+ if (camelContext.isSourceLocationEnabled()) {
+ name = getLineNumberLoggerName(definition);
+ if (name != null) {
+ LOG.debug("LogName is not configured, using source location as logName: {}", name);
+ }
+ }
if (name == null) {
name = route.getRouteId();
LOG.debug("LogName is not configured, using route id as logName: {}", name);