Skip to content

Commit

Permalink
Removed the deprecated --logging-level option (issue apache#2000)
Browse files Browse the repository at this point in the history
  • Loading branch information
orpiske committed Jun 11, 2021
1 parent 48fb17a commit 60a93fc
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 17 deletions.
36 changes: 36 additions & 0 deletions docs/modules/ROOT/pages/observability/integration-logging.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[[integration-logging]]
= Camel K Integration Logging

Starting with https://camel.apache.org/blog/2021/05/new-camel-k-logging-features/[Camel K 1.5], we introduced a new
xref:traits:logging.adoc[logging trait] that simplifies access to the logging configuration available on the runtime.


[[integration-logging-level]]
== Logging Level

To configure the log level, pass one of the supported log levels to the trait. For example:

```
--trait logging.level=DEBUG
```


[[integration-logging-format]]
== Logging Format

The format of the logging message can also be configured using one of the supported log format options from
https://quarkus.io/guides/logging[Quarkus] (which provides the logging framework for Camel Quarkus which is leveraged by
Camel K).

A sample custom configuration would look like this:

```
--trait logging.format='%d{HH:mm:ss} %-5p (%t) %s%e%n'.
```

[[integration-logging-structured]]
== Structured Logs in Json Format

Like the operator, the integrations will use structured logs to facilitate collection and parsing. This can be turned on
or off using the `--trait logging.json` trait. Subsequently, it can also be customized to output pretty json logs by
setting the `logging.json.pretty-print` trait.
6 changes: 6 additions & 0 deletions docs/modules/ROOT/pages/observability/logging.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[logging]]
= Camel K Logging

The Camel K logging has two major areas. The first one is related to the logging provided by the
xref:observability/operator-logging.adoc[operator itself], whereas the second is related to the
xref:observability/integration-logging.adoc[integrations] ran by Camel K.
16 changes: 16 additions & 0 deletions docs/modules/ROOT/pages/observability/operator-logging.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[[logging]]
= Camel K Operator Logging

The Camel K Operator logging is mostly managed by the Kubernetes infrastructure, with some specific aspects managed by
Camel K itself. The operator uses https://kubernetes.io/blog/2020/09/04/kubernetes-1-19-introducing-structured-logs/[structured logs]
so that the logs are more easily parseable.

This includes the output of components managed by the operator, such as the maven build, and the integration container build.
For example, the maven build logs should be displayed like this:


```
{"level":"info","ts":1620393185.321101,"logger":"camel-k.maven.build","msg":"Downloading from repository-000: http://my.repository.com:8081/artifactory/fuse-brno/org/jboss/shrinkwrap/resolver/shrinkwrap-resolver-bom/2.2.4/shrinkwrap-resolver-bom-2.2.4.pom"}
```

There are some exceptions to this, though, and they are mostly related to running the operator for development purposes.
5 changes: 0 additions & 5 deletions pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ func newCmdRun(rootCmdOptions *RootCmdOptions) (*cobra.Command, *runCmdOptions)
cmd.Flags().Bool("use-flows", true, "Write yaml sources as Flow objects in the integration custom resource")
cmd.Flags().String("profile", "", "Trait profile used for deployment")
cmd.Flags().StringArrayP("trait", "t", nil, "Configure a trait. E.g. \"-t service.enabled=false\"")
cmd.Flags().StringArray("logging-level", nil, "Configure the logging level. e.g. \"--logging-level org.apache.camel=DEBUG\"")
cmd.Flags().StringP("output", "o", "", "Output format. One of: json|yaml")
cmd.Flags().Bool("compression", false, "Enable storage of sources and resources as a compressed binary blobs")
cmd.Flags().StringArray("resource", nil, "Add a resource")
Expand Down Expand Up @@ -136,7 +135,6 @@ type runCmdOptions struct {
Secrets []string `mapstructure:"secrets" yaml:",omitempty"`
Repositories []string `mapstructure:"maven-repositories" yaml:",omitempty"`
Traits []string `mapstructure:"traits" yaml:",omitempty"`
LoggingLevels []string `mapstructure:"logging-levels" yaml:",omitempty"`
Volumes []string `mapstructure:"volumes" yaml:",omitempty"`
EnvVars []string `mapstructure:"envs" yaml:",omitempty"`
// Deprecated: PropertyFiles has been deprecated in 1.5
Expand Down Expand Up @@ -597,9 +595,6 @@ func (o *runCmdOptions) updateIntegrationCode(c client.Client, sources []string,
}
}
}
for _, item := range o.LoggingLevels {
integration.Spec.AddConfiguration("property", "logging.level."+item)
}
for _, item := range o.Configs {
if config, parseErr := ParseConfigOption(item); parseErr == nil {
if applyConfigOptionErr := ApplyConfigOption(config, &integration.Spec, c, namespace, o.Compression); applyConfigOptionErr != nil {
Expand Down
12 changes: 0 additions & 12 deletions pkg/cmd/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,6 @@ func TestRunLabelWrongFormatFlag(t *testing.T) {
assert.NotNil(t, err)
}

func TestRunLoggingLevelFlag(t *testing.T) {
runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t)
_, err := test.ExecuteCommand(rootCmd, cmdRun,
"--logging-level", "lev1",
"--logging-level", "lev2",
integrationSource)
assert.Nil(t, err)
assert.Len(t, runCmdOptions.LoggingLevels, 2)
assert.Equal(t, "lev1", runCmdOptions.LoggingLevels[0])
assert.Equal(t, "lev2", runCmdOptions.LoggingLevels[1])
}

func TestRunLogsFlag(t *testing.T) {
runCmdOptions, rootCmd, _ := initializeRunCmdOptions(t)
_, err := test.ExecuteCommand(rootCmd, cmdRun, "--logs", integrationSource)
Expand Down

0 comments on commit 60a93fc

Please sign in to comment.