-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
W-11984725-logger-revamp-duke #2402
Open
dukesphere
wants to merge
15
commits into
v4.4
Choose a base branch
from
W-11984725-logger-revamp-duke
base: v4.4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e5e634c
W-11984725-logger-revamp-duke
dukesphere 6b0188e
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere 8c896f1
W-11984725-logger-revamp-duke
dukesphere 7086991
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere cc63bf0
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere 788f7c8
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere 1c1f03e
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere 35492b7
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere ac632d1
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere 447c0e3
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere 48d4009
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere e8a51f5
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere 0e2636b
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere f57a925
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere aca0430
Update modules/ROOT/pages/logger-component-reference.adoc
dukesphere File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,74 +6,99 @@ endif::[] | |
|
||
This Core component helps you monitor and debug your Mule application by logging important information such as error messages, status notifications, payloads, and so on. You can add a Logger anywhere in a flow, and you can configure it to log a string that you specify, the output of a DataWeave expression you write, or any combination of strings and expressions. | ||
|
||
[WARNING] | ||
-- | ||
Keep in mind that the Logger is one of the only components that supports mixing Strings and expressions within a value. DataWeave String interpolation or concatenation within a single expression should be used elsewhere. | ||
-- | ||
//TODO: IS THIS TRUE BEYOND ON-PREM INSTALLATIONS? | ||
The configured messages are logged in a Mule application's log file, which is located in `MULE_HOME/logs/<app-name>.log` if no custom log file path is specified in the `log4j2.xml` file. For details, see xref:logging-and-debugging.adoc[]. | ||
|
||
The configured messages are logged to the app's log file, which is located in `MULE_HOME/logs/<app-name>.log` if no custom log file path is specified in the `log4j2.xml` file. + | ||
In Studio, the logs show in the Console. | ||
In Anypoint Studio, the logs print to the xref:studio::index.adoc#console[console]. | ||
|
||
The following example displays the message in Set Payload in a browser and also logs the message. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed bc "... in a browser": it's in the browser bc of the request to the listener, not directly relevant to logger |
||
The following example logs the message `Hello MuleSoft!`. | ||
|
||
image::logger-flow.png[] | ||
|
||
.Example: XML Configuration of the Flow | ||
[source,xml,linenums] | ||
---- | ||
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081"/> | ||
<flow name="logger-example-Flow"> | ||
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" > | ||
<http:listener-connection host="0.0.0.0" port="8081" /> | ||
</http:listener-config><flow name="logger-example-Flow"> | ||
<http:listener config-ref="HTTP_Listener_Configuration" path="/"/> | ||
<set-payload value="Hello MuleSoft!"/> | ||
<logger message="#[payload]" level="INFO"/> | ||
</flow> | ||
---- | ||
|
||
== Logger Configuration | ||
In the Studio console, the logged message, `Hello MuleSoft!` looks like this: | ||
|
||
[source,logs] | ||
---- | ||
INFO 2022-11-10 19:39:18,222 [[MuleRuntime].uber.01: [w-logger].logger-example-Flow.CPU_LITE @6f862394] | ||
[processor: logger-example-Flow/processors/1; event: 6bd2b350-6172-11ed-9f87-147ddaaf4f97] | ||
org.mule.runtime.core.internal.processor.LoggerMessageProcessor: Hello MuleSoft! | ||
---- | ||
|
||
* The configurable log level is `INFO`. See <<reference>>. | ||
* A date-time stamp `2022-11-10 19:39:18,222` indicates when the Logger executes. | ||
* CPU_LITE is the See xref:execution-engine.adoc#processing_types[processing type]. | ||
* `event: 6bd2b350-6172-11ed-9f87-147ddaaf4f97` identifies the Mule event. | ||
* The message processor `org.mule.runtime.core.internal.processor.LoggerMessageProcessor` prints the message `Hello MuleSoft!`. | ||
|
||
[[reference]] | ||
== Reference | ||
|
||
image::logger.png[] | ||
|
||
[%header%autowidth.spread,cols="a,a,a,a"] | ||
[%header%autowidth.spread,cols="1a,1a,1a,4a"] | ||
|=== | ||
| Field | Value | Description | Example | ||
| Field | Attribute | Value | Description | ||
|
||
| Message | String or DataWeave expression | Specifies the Mule log message. By default, messages are logged to the application's log file. | | ||
`message="Current payload is #[payload]"` | ||
| *Message* | `message` | String or DataWeave expression | Specifies the Mule log message. By default, messages are logged to the application's log file. Example: | ||
`message="Current payload is #[payload]"`. Note that the Logger is one of the only components that supports this syntax to embed an expression (such as `#[payload]` within a string. Messages in other Mule components require string interpolation or concatenation within a single DataWeave expression. | ||
|
||
| Level | | ||
Available options: | ||
| Level | `level` | Available options: | ||
|
||
* `DEBUG` | ||
* `ERROR` | ||
* `INFO`(Default) | ||
* `TRACE` | ||
* `WARN` | | ||
Specifies the log level. | ||
|
||
| | ||
`level="ERROR"` | ||
Specifies the log level. Example: `level="ERROR"` | ||
|
||
| Category | String | Optional setting that specifies a category name that it adds to `log4j2.xml` file. For example, you might use a category to route your log messages based on your category, or you might set log levels based on category. | | ||
| Category | `category` | String | Optional setting that specifies a category name that it adds to `log4j2.xml` file. For example, you might use a category to route your log messages based on your category, or you might set log levels based on category. Example: | ||
`category="MyCustomCategory"` | ||
|
||
|=== | ||
|
||
== Examples | ||
|
||
This Logger is set to monitor message processing status, mixing Strings and expressions: | ||
This Logger monitors message processing status, mixing strings with a DataWeave selector expressions: | ||
|
||
[source,xml,linenums] | ||
[source,xml] | ||
---- | ||
<logger category="monitoring" message="Message #[payload.id] processed successfully" level="INFO"/> | ||
---- | ||
|
||
This Logger set to record the processing time of a flow, using a single expression and DataWeave's String concatenation: | ||
Assuming a payload such as `{"id" : "100", "some-key" : "some value" }`, the Logger prints the message `Message 100 processed successfully`, for example: | ||
|
||
[source,xml,linenums] | ||
[source,xml] | ||
---- | ||
<logger category="performance" message="#['Message ' ++ payload.id ++ ' took ' ++ vars.processingTime ++ ' milliseconds to process']" level="INFO"/> | ||
INFO 2022-11-10 21:11:07,791 [[MuleRuntime].uber.09: [w-logger].logger-example-Flow.CPU_LITE @600dcddb] | ||
[processor: logger-example-Flow/processors/1; event: 3fd13710-617f-11ed-900f-147ddaaf4f97] | ||
org.mule.runtime.core.internal.processor.LoggerMessageProcessor: Message 100 processed successfully | ||
---- | ||
|
||
This Logger records the processing time of a flow, using a single expression and DataWeave concatenation: | ||
|
||
//TODO: Need to show how to get processing time or use a better example that doesn't throw an error. | ||
[source,xml] | ||
---- | ||
<logger category="performance" message="#['Message ' ++ payload.id ++ ' took ' ++ vars.processingTime ++ ' milliseconds to process']" level="INFO"/> | ||
---- | ||
|
||
== Streamed Data | ||
|
||
//TODO: say something about how a logger handles streamed content | ||
|
||
|
||
== See also | ||
|
||
xref:dataweave::dataweave-types.adoc#dw_type_string[DataWeave String Type] | ||
* xref:dataweave::dataweave-types.adoc#dw_type_string[DataWeave String Type] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to reference