Skip to content

Commit 3f2647f

Browse files
committed
update logging recipe
1 parent f5a2025 commit 3f2647f

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

docs/recipes/logging.md

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,32 +95,30 @@ Lucee also provides the following layouts for customizing log output:
9595
- **classic**: Produces traditional CFML-compatible output.
9696
- **datadog**: Formats logs for direct ingestion into **Datadog**.
9797
- **html**: Outputs logs in an HTML format suitable for browser-based debugging.
98-
- **json**: Generates logs in structured JSON format.
98+
- **json**: Generates logs in structured JSON format (uses Log4j2's JSONAppender internally).
9999
- **pattern**: Allows custom patterns for maximum flexibility.
100100
- **xml**: Outputs logs in structured XML format.
101101

102102
---
103103

104104
## Extending Logging with Custom Appenders and Layouts
105105

106-
In addition to the built-in appenders and layouts, Lucee supports custom configurations using third-party libraries.
107-
You can use OSGi based libraries or classic java libraries (Maven support will follow soon).
108-
Here’s how you can define custom appenders and layouts:
106+
In addition to the built-in appenders and layouts, Lucee supports custom configurations using third-party libraries. Here’s how you can define custom appenders and layouts:
109107

110108
### Custom Appender Configuration
111109

112110
```json
113111
"appenderClass": "<custom-appender-class-name>",
114-
"appenderBundleName": "<custom-appender-osgi-bundle-name>", // only needed for OSGi based libraries
115-
"appenderBundleVersion": "<custom-appender-osgi-bundle-version>" // only needed for OSGi based libraries
112+
"appenderBundleName": "<custom-appender-osgi-bundle-name>",
113+
"appenderBundleVersion": "<custom-appender-osgi-bundle-version>"
116114
```
117115

118116
### Custom Layout Configuration
119117

120118
```json
121119
"layoutClass": "<custom-layout-class-name>",
122-
"layoutBundleName": "<custom-layout-osgi-bundle-name>", // only needed for OSGi based libraries
123-
"layoutBundleVersion": "<custom-layout-osgi-bundle-version>" // only needed for OSGi based libraries
120+
"layoutBundleName": "<custom-layout-osgi-bundle-name>",
121+
"layoutBundleVersion": "<custom-layout-osgi-bundle-version>"
124122
```
125123

126124
### Example: Custom Logging to Kafka
@@ -150,4 +148,35 @@ This configuration sends logs to a Kafka topic with a custom pattern layout.
150148

151149
---
152150

151+
## Using the `<cflog>` Tag
152+
153+
Lucee supports logging through the `<cflog>` tag, which allows you to send log entries to specific loggers. The tag is available in both **HTML-style** and **script-style** syntax.
154+
155+
### Examples
156+
157+
#### HTML-Style Syntax
158+
159+
```html
160+
<cflog log="application" type="warn" text="Warning: Something went wrong!">
161+
```
162+
163+
#### Script-Style Syntax (Migration)
164+
165+
```javascript
166+
log log="application" type="warn" text="Warning: Something went wrong!";
167+
```
168+
169+
#### Script-Style Syntax (Function)
170+
171+
```javascript
172+
try {
173+
throw "Warning: Something went wrong!"
174+
}
175+
catch(e) {
176+
cflog(log="application", type="error", exception=e);
177+
}
178+
```
179+
180+
Lucee's `<cflog>` tag supports various attributes, including `log`, `type`, `text`, and `exception`. Using these attributes, you can customize log entries to suit your application's needs.
181+
153182
Lucee’s extensible logging framework offers flexibility for integrating with diverse infrastructures, enhancing monitoring, debugging, and auditing capabilities. By leveraging built-in features and custom configurations, you can adapt the logging system to your application's unique needs.

0 commit comments

Comments
 (0)