Skip to content

Commit e950cc8

Browse files
pkalsi97squakez
authored andcommitted
chore(trait): deprecate logging trait in favor of Quarkus properties
1 parent ac62461 commit e950cc8

File tree

5 files changed

+151
-2
lines changed

5 files changed

+151
-2
lines changed

docs/modules/ROOT/partials/apis/camel-k-crds.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8252,6 +8252,14 @@ If this is true, the created Knative trigger uses the event type as a filter on
82528252
The Logging trait is used to configure Integration runtime logging options (such as color and format).
82538253
The logging backend is provided by Quarkus, whose configuration is documented at https://quarkus.io/guides/logging.
82548254
8255+
WARNING: The Logging trait is **deprecated** and will be removed in future release versions:
8256+
use Quarkus logging properties directly instead.
8257+
8258+
Migration example:
8259+
8260+
Before: traits.logging.level=DEBUG
8261+
After: -p quarkus.log.level=DEBUG
8262+
82558263
82568264
[cols="2,2a",options="header"]
82578265
|===

docs/modules/traits/pages/logging.adoc

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
= Logging Trait
22

33
// Start of autogenerated code - DO NOT EDIT! (badges)
4+
[.badges]
5+
[.badge-key]##Deprecated since##[.badge-unsupported]##2.9.0##
46
// End of autogenerated code - DO NOT EDIT! (badges)
7+
8+
[WARNING]
9+
====
10+
The Logging trait is *deprecated* as of version 2.9.0 and will be removed in a future release.
11+
12+
Please use Quarkus logging properties directly instead. See the <<migration-guide>> section below for details.
13+
====
14+
515
// Start of autogenerated code - DO NOT EDIT! (description)
616
The Logging trait is used to configure Integration runtime logging options (such as color and format).
717
The logging backend is provided by Quarkus, whose configuration is documented at https://quarkus.io/guides/logging.
818

19+
WARNING: The Logging trait is **deprecated** and will be removed in future release versions:
20+
use Quarkus logging properties directly instead.
21+
22+
Migration example:
23+
24+
Before: traits.logging.level=DEBUG
25+
After: -p quarkus.log.level=DEBUG
26+
927

1028
This trait is available in the following profiles: **Kubernetes, Knative, OpenShift**.
1129

@@ -51,3 +69,91 @@ The following configuration options are available:
5169
|===
5270

5371
// End of autogenerated code - DO NOT EDIT! (configuration)
72+
73+
[[migration-guide]]
74+
== Migration Guide
75+
76+
The Logging trait is deprecated. You should migrate to using Quarkus properties directly, which provides the same functionality with more flexibility.
77+
78+
=== Property Mapping
79+
80+
The following table shows how to map Logging trait properties to Quarkus properties:
81+
82+
[cols="2m,2m,3a"]
83+
|===
84+
|Logging Trait | Quarkus Property | Example
85+
86+
| logging.level=DEBUG
87+
| quarkus.log.level=DEBUG
88+
| `kamel run -p quarkus.log.level=DEBUG MyRoute.java`
89+
90+
| logging.color=true
91+
| quarkus.console.color=true
92+
| `kamel run -p quarkus.console.color=true MyRoute.java`
93+
94+
| logging.format=...
95+
| quarkus.log.console.format=...
96+
| `kamel run -p quarkus.log.console.format="%d{HH:mm:ss} %-5p %s%e%n" MyRoute.java`
97+
98+
| logging.json=true
99+
| quarkus.log.console.json=true
100+
| `kamel run -p quarkus.log.console.json=true MyRoute.java`
101+
102+
| logging.json-pretty-print=true
103+
| quarkus.log.console.json.pretty-print=true
104+
| `kamel run -p quarkus.log.console.json.pretty-print=true MyRoute.java`
105+
106+
|===
107+
108+
=== Migration Examples
109+
110+
**Before (deprecated):**
111+
112+
[source,yaml]
113+
----
114+
apiVersion: camel.apache.org/v1
115+
kind: Integration
116+
metadata:
117+
name: my-integration
118+
spec:
119+
traits:
120+
logging:
121+
level: DEBUG
122+
json: true
123+
jsonPrettyPrint: true
124+
----
125+
126+
**After (recommended):**
127+
128+
[source,yaml]
129+
----
130+
apiVersion: camel.apache.org/v1
131+
kind: Integration
132+
metadata:
133+
name: my-integration
134+
spec:
135+
configuration:
136+
- type: property
137+
value: quarkus.log.level=DEBUG
138+
- type: property
139+
value: quarkus.log.console.json=true
140+
- type: property
141+
value: quarkus.log.console.json.pretty-print=true
142+
----
143+
144+
Or using the CLI:
145+
146+
[source,console]
147+
----
148+
$ kamel run MyRoute.java \
149+
-p quarkus.log.level=DEBUG \
150+
-p quarkus.log.console.json=true \
151+
-p quarkus.log.console.json.pretty-print=true
152+
----
153+
154+
=== Benefits of Direct Properties
155+
156+
Using Quarkus properties directly provides more flexibility, including:
157+
158+
* Category-specific log levels: `quarkus.log.category."org.apache.camel".level=DEBUG`
159+
* More logging options available at https://quarkus.io/guides/logging

pkg/apis/camel/v1/trait/logging.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@ package trait
2020
// The Logging trait is used to configure Integration runtime logging options (such as color and format).
2121
// The logging backend is provided by Quarkus, whose configuration is documented at https://quarkus.io/guides/logging.
2222
//
23+
// WARNING: The Logging trait is **deprecated** and will be removed in future release versions:
24+
// use Quarkus logging properties directly instead.
25+
//
26+
// Migration example:
27+
//
28+
// Before: traits.logging.level=DEBUG
29+
// After: -p quarkus.log.level=DEBUG
30+
//
2331
// +camel-k:trait=logging.
32+
// +camel-k:deprecated=2.9.0.
2433
type LoggingTrait struct {
2534
Trait `json:",inline" property:",squash"`
2635

pkg/trait/logging.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ limitations under the License.
1818
package trait
1919

2020
import (
21+
corev1 "k8s.io/api/core/v1"
22+
"k8s.io/utils/ptr"
23+
24+
v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
2125
traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
2226
"github.com/apache/camel-k/v2/pkg/util/boolean"
23-
"k8s.io/utils/ptr"
2427
)
2528

2629
const (
@@ -54,7 +57,17 @@ func (l *loggingTrait) Configure(e *Environment) (bool, *TraitCondition, error)
5457
return false, NewIntegrationConditionUserDisabled("Logging"), nil
5558
}
5659

57-
return e.IntegrationInRunningPhases(), nil, nil
60+
condition := NewIntegrationCondition(
61+
"Logging",
62+
v1.IntegrationConditionTraitInfo,
63+
corev1.ConditionTrue,
64+
TraitConfigurationReason,
65+
"Logging trait is deprecated and may be removed in future versions. "+
66+
"Use Quarkus properties directly (e.g., quarkus.log.level, quarkus.log.console.json). "+
67+
"See https://quarkus.io/guides/logging for more details.",
68+
)
69+
70+
return e.IntegrationInRunningPhases(), condition, nil
5871
}
5972

6073
func (l *loggingTrait) Apply(e *Environment) error {

pkg/trait/logging_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,16 @@ func TestJsonLoggingTrait(t *testing.T) {
154154
assert.Equal(t, "${camel.k.logging.jsonPrettyPrint}", env.ApplicationProperties["quarkus.log.console.json.pretty-print"])
155155
assert.Equal(t, "", env.ApplicationProperties["quarkus.console.color"])
156156
}
157+
158+
func TestLoggingTraitDeprecationWarning(t *testing.T) {
159+
env := createDefaultLoggingTestEnv(t)
160+
loggingTrait := newLoggingTraitTrait()
161+
162+
configured, condition, err := loggingTrait.Configure(env)
163+
164+
require.NoError(t, err)
165+
assert.True(t, configured)
166+
assert.NotNil(t, condition)
167+
assert.Contains(t, condition.message, "Logging trait is deprecated")
168+
assert.Contains(t, condition.message, "Quarkus properties")
169+
}

0 commit comments

Comments
 (0)