Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/modules/ROOT/partials/apis/camel-k-crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8252,6 +8252,14 @@ If this is true, the created Knative trigger uses the event type as a filter on
The Logging trait is used to configure Integration runtime logging options (such as color and format).
The logging backend is provided by Quarkus, whose configuration is documented at https://quarkus.io/guides/logging.

WARNING: The Logging trait is **deprecated** and will be removed in future release versions:
use Quarkus logging properties directly instead.

Migration example:

Before: traits.logging.level=DEBUG
After: -p quarkus.log.level=DEBUG


[cols="2,2a",options="header"]
|===
Expand Down
106 changes: 106 additions & 0 deletions docs/modules/traits/pages/logging.adoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
= Logging Trait

// Start of autogenerated code - DO NOT EDIT! (badges)
[.badges]
[.badge-key]##Deprecated since##[.badge-unsupported]##2.9.0##
// End of autogenerated code - DO NOT EDIT! (badges)

[WARNING]
====
The Logging trait is *deprecated* as of version 2.9.0 and will be removed in a future release.

Please use Quarkus logging properties directly instead. See the <<migration-guide>> section below for details.
====

// Start of autogenerated code - DO NOT EDIT! (description)
The Logging trait is used to configure Integration runtime logging options (such as color and format).
The logging backend is provided by Quarkus, whose configuration is documented at https://quarkus.io/guides/logging.

WARNING: The Logging trait is **deprecated** and will be removed in future release versions:
use Quarkus logging properties directly instead.

Migration example:

Before: traits.logging.level=DEBUG
After: -p quarkus.log.level=DEBUG


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

Expand Down Expand Up @@ -51,3 +69,91 @@ The following configuration options are available:
|===

// End of autogenerated code - DO NOT EDIT! (configuration)

[[migration-guide]]
== Migration Guide

The Logging trait is deprecated. You should migrate to using Quarkus properties directly, which provides the same functionality with more flexibility.

=== Property Mapping

The following table shows how to map Logging trait properties to Quarkus properties:

[cols="2m,2m,3a"]
|===
|Logging Trait | Quarkus Property | Example

| logging.level=DEBUG
| quarkus.log.level=DEBUG
| `kamel run -p quarkus.log.level=DEBUG MyRoute.java`

| logging.color=true
| quarkus.console.color=true
| `kamel run -p quarkus.console.color=true MyRoute.java`

| logging.format=...
| quarkus.log.console.format=...
| `kamel run -p quarkus.log.console.format="%d{HH:mm:ss} %-5p %s%e%n" MyRoute.java`

| logging.json=true
| quarkus.log.console.json=true
| `kamel run -p quarkus.log.console.json=true MyRoute.java`

| logging.json-pretty-print=true
| quarkus.log.console.json.pretty-print=true
| `kamel run -p quarkus.log.console.json.pretty-print=true MyRoute.java`

|===

=== Migration Examples

**Before (deprecated):**

[source,yaml]
----
apiVersion: camel.apache.org/v1
kind: Integration
metadata:
name: my-integration
spec:
traits:
logging:
level: DEBUG
json: true
jsonPrettyPrint: true
----

**After (recommended):**

[source,yaml]
----
apiVersion: camel.apache.org/v1
kind: Integration
metadata:
name: my-integration
spec:
configuration:
- type: property
value: quarkus.log.level=DEBUG
- type: property
value: quarkus.log.console.json=true
- type: property
value: quarkus.log.console.json.pretty-print=true
----

Or using the CLI:

[source,console]
----
$ kamel run MyRoute.java \
-p quarkus.log.level=DEBUG \
-p quarkus.log.console.json=true \
-p quarkus.log.console.json.pretty-print=true
----

=== Benefits of Direct Properties

Using Quarkus properties directly provides more flexibility, including:

* Category-specific log levels: `quarkus.log.category."org.apache.camel".level=DEBUG`
* More logging options available at https://quarkus.io/guides/logging
9 changes: 9 additions & 0 deletions pkg/apis/camel/v1/trait/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ package trait
// The Logging trait is used to configure Integration runtime logging options (such as color and format).
// The logging backend is provided by Quarkus, whose configuration is documented at https://quarkus.io/guides/logging.
//
// WARNING: The Logging trait is **deprecated** and will be removed in future release versions:
// use Quarkus logging properties directly instead.
//
// Migration example:
//
// Before: traits.logging.level=DEBUG
// After: -p quarkus.log.level=DEBUG
//
// +camel-k:trait=logging.
// +camel-k:deprecated=2.9.0.
type LoggingTrait struct {
Trait `json:",inline" property:",squash"`

Expand Down
17 changes: 15 additions & 2 deletions pkg/trait/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ limitations under the License.
package trait

import (
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/ptr"

v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
traitv1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1/trait"
"github.com/apache/camel-k/v2/pkg/util/boolean"
"k8s.io/utils/ptr"
)

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

return e.IntegrationInRunningPhases(), nil, nil
condition := NewIntegrationCondition(
"Logging",
v1.IntegrationConditionTraitInfo,
corev1.ConditionTrue,
TraitConfigurationReason,
"Logging trait is deprecated and may be removed in future versions. "+
"Use Quarkus properties directly (e.g., quarkus.log.level, quarkus.log.console.json). "+
"See https://quarkus.io/guides/logging for more details.",
)

return e.IntegrationInRunningPhases(), condition, nil
}

func (l *loggingTrait) Apply(e *Environment) error {
Expand Down
13 changes: 13 additions & 0 deletions pkg/trait/logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,16 @@ func TestJsonLoggingTrait(t *testing.T) {
assert.Equal(t, "${camel.k.logging.jsonPrettyPrint}", env.ApplicationProperties["quarkus.log.console.json.pretty-print"])
assert.Equal(t, "", env.ApplicationProperties["quarkus.console.color"])
}

func TestLoggingTraitDeprecationWarning(t *testing.T) {
env := createDefaultLoggingTestEnv(t)
loggingTrait := newLoggingTraitTrait()

configured, condition, err := loggingTrait.Configure(env)

require.NoError(t, err)
assert.True(t, configured)
assert.NotNil(t, condition)
assert.Contains(t, condition.message, "Logging trait is deprecated")
assert.Contains(t, condition.message, "Quarkus properties")
}
Loading