You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/recipes/logging.md
+30-68Lines changed: 30 additions & 68 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,27 +18,15 @@
18
18
}
19
19
-->
20
20
21
-
# Logging in Lucee
21
+
# Logging
22
22
23
-
Lucee's logging system is a powerful and flexible framework designed to provide insights into your application’s behavior.
23
+
Logging helps you monitor errors, track events, and troubleshoot your applications. Lucee's logging system is built on Log4j2, giving you flexible control over what gets logged, where it goes, and how it's formatted.
24
24
25
-
By configuring logs, you can monitor errors, track events, and troubleshoot efficiently.
25
+
You can configure log levels to control verbosity, choose appenders to direct output (console, files, databases, or custom destinations like Kafka), and select layouts to format the output.
26
26
27
-
## Why Logging?
27
+
## Log Levels
28
28
29
-
Logging is an essential practice for maintaining reliable and performant applications. It allows you to:
30
-
31
-
- Monitor runtime behavior and identify issues.
32
-
- Gain insights into application usage and performance.
33
-
- Maintain an audit trail of events and actions.
34
-
35
-
Lucee supports various log types (or levels), enabling you to control the verbosity and focus of your logs.
36
-
37
-
Additionally, you can configure logging destinations and formats to integrate seamlessly with your infrastructure.
38
-
39
-
## How to Use Log Levels?
40
-
41
-
Log levels (or types) categorize log entries based on their importance or severity. Lucee supports the following log levels in decreasing order of severity:
29
+
In decreasing order of severity:
42
30
43
31
-**fatal**: Severe errors causing premature termination.
44
32
-**error**: Runtime errors or unexpected conditions that require attention.
@@ -47,17 +35,13 @@ Log levels (or types) categorize log entries based on their importance or severi
47
35
-**debug**: Detailed information helpful for debugging issues.
48
36
-**trace**: The most detailed information for fine-grained troubleshooting.
49
37
50
-
### Configuring Log Level Thresholds
38
+
### Log Level Thresholds
51
39
52
-
You can configure the minimum log level (threshold) for each logger in the **Lucee Administrator** or directly in the configuration file (`.CFConfig.json`).
40
+
Configure minimum log level per logger in **Lucee Administrator** or `.CFConfig.json`. Setting threshold to `warn` records only warnings, errors, and fatal - ignoring `info`, `debug`, and `trace`.
53
41
54
-
For instance, setting a threshold of `warn` means only warnings, errors, and fatal logs are recorded, ignoring `info`, `debug`, and `trace` logs.
42
+
### Redirecting Logs to Console
55
43
56
-
This allows you to start with minimal logging in production and increase verbosity (e.g., to `debug`) for deeper analysis when needed.
57
-
58
-
### Redirecting all logs to the console
59
-
60
-
Lucee 6.2 supports the following environment variables which allow overriding the log levels and appender, which is great for debugging and Docker
44
+
Since Lucee 6.2, override log levels and appender via environment variables:
## Extending Logging with Custom Appenders and Layouts
103
+
## Custom Appenders and Layouts
130
104
131
-
In addition to the built-in Appenders and Layouts, Lucee supports custom configurations using third-party libraries.
132
-
133
-
Here’s how you can define custom Appenders and Layouts:
105
+
Extend with third-party libraries:
134
106
135
107
### Custom Appender Configuration
136
108
@@ -171,29 +143,23 @@ Here’s how you can define custom Appenders and Layouts:
171
143
}
172
144
```
173
145
174
-
This configuration sends logs to a Kafka topic with a custom pattern Layout.
175
-
176
-
---
146
+
Sends logs to a Kafka topic with custom pattern layout.
177
147
178
-
## Using the `<cflog>` Tag
148
+
## Using `<cflog>`
179
149
180
-
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.
181
-
182
-
### Examples
183
-
184
-
#### HTML-Style Syntax
150
+
### Tag Syntax
185
151
186
152
```html
187
153
<cfloglog="application"type="warn"text="Warning: Something went wrong!">
188
154
```
189
155
190
-
####Script-Style Syntax (Migration)
156
+
### Script Syntax
191
157
192
158
```javascript
193
159
log log="application" type="warn" text="Warning: Something went wrong!";
194
160
```
195
161
196
-
#### Script-Style Syntax (Function)
162
+
###Function Syntax
197
163
198
164
```javascript
199
165
try {
@@ -204,8 +170,4 @@ catch(e) {
204
170
}
205
171
```
206
172
207
-
(Due to the existing math log function, the cf prefix is still required here, unlike with other tags in script.)
208
-
209
-
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.
210
-
211
-
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.
173
+
Note: Due to the existing math `log` function, the `cf` prefix is required here unlike other tags in script.
Copy file name to clipboardExpand all lines: docs/recipes/lucene-search.md
+5-10Lines changed: 5 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,18 +24,13 @@
24
24
25
25
# Lucene 3 Extension
26
26
27
-
The Lucene 3 Extension introduces significant enhancements to Lucee's search capabilities, including vector-based semantic search, hybrid search combining keyword and vector approaches, and improved content chunking for more relevant results.
27
+
The Lucene 3 Extension brings modern search capabilities to Lucee, including vector-based semantic search that understands meaning rather than just matching keywords. You can use traditional keyword search, pure vector search, or combine both in hybrid mode for best results.
28
28
29
-
## Overview
29
+
Key features:
30
30
31
-
Lucene 3 is a major update to Lucee's search functionality, bringing modern search techniques to your applications. This version introduces:
32
-
33
-
- Vector-based semantic search using document embeddings
34
-
- Hybrid search combining traditional keyword search with vector search
35
-
- Enhanced content chunking with passage extraction
36
-
- Improved relevance scoring and result highlighting
37
-
38
-
These features enable more natural language understanding in search operations and provide better support for AI augmentation through Retrieval-Augmented Generation (RAG) patterns.
31
+
-**Vector search** - find conceptually similar content using embeddings
32
+
-**Hybrid search** - combine keyword and vector approaches
Copy file name to clipboardExpand all lines: docs/recipes/migrate.from.classic-to-modern-local-scope.md
+33-84Lines changed: 33 additions & 84 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,31 +17,25 @@
17
17
18
18
# Migrating from Classic to Modern Local Scope Mode
19
19
20
-
Lucee offers two different modes for managing unscoped variables within functions: Classic and Modern.
20
+
Lucee offers two modes for handling unscoped variables in functions: Classic and Modern.
21
21
22
-
This document explains the differences between these modes and provides a structured approach for migrating from Classic to Modern mode.
23
-
24
-
Simply switching to `localmode=true`, either per function or Application wide, will dramatically boost the performance of your Lucee applications, but requires testing.
22
+
Switching to `localmode=true` (per function or application-wide) dramatically boosts performance, but requires testing.
25
23
26
24
## Understanding Local Scope Modes
27
25
28
-
The "Local scope mode" setting defines how variables with no explicit scope are handled within functions:
26
+
The local scope mode setting defines how unscoped variables are handled in functions:
29
27
30
-
***Classic Mode (CFML Default)**: Unscoped variables are stored in the variables scope, unless the key already exists in one of the function's local scopes (arguments or local).
31
-
***Modern Mode**: Unscoped variables are always stored in the local scope, regardless of whether they exist elsewhere.
28
+
-**Classic Mode** (CFML default): Unscoped variables go to `variables` scope, unless the key exists in `arguments` or `local`.
29
+
-**Modern Mode**: Unscoped variables always go to `local` scope.
32
30
33
31
## Why Migrate to Modern Mode?
34
32
35
-
Modern mode offers several advantages:
36
-
37
-
1.**Thread Safety**: Variables are isolated to the function instance, preventing race conditions when component instances are shared across requests.
38
-
2.**Predictable Behavior**: All unscoped variables behave the same way, making code more intuitive and easier to maintain.
39
-
3.**Performance**: Local scope lookups are typically faster than cascading scope resolution.
33
+
-**Thread Safety**: Variables isolated to function instance - prevents race conditions with shared components
34
+
-**Predictable Behavior**: All unscoped variables behave the same way
35
+
-**Performance**: Local scope lookups are faster than cascading scope resolution
40
36
41
37
### Classic Mode Race Condition Example
42
38
43
-
Consider this component when running in Classic mode:
44
-
45
39
```cfml
46
40
component {
47
41
function createToken(id) {
@@ -52,39 +46,29 @@ component {
52
46
}
53
47
```
54
48
55
-
If this component is stored in application scope and used across multiple concurrent requests, `token` becomes a shared variable. This creates a race condition where multiple threads could overwrite each other's values.
49
+
If this component is in application scope and used concurrently, `token` becomes shared - multiple threads can overwrite each other's values.
56
50
57
51
## Configuring Local Scope Mode
58
52
59
-
Local scope mode can be configured at several levels:
60
-
61
-
### 1. Server Level (Lucee Administrator)
53
+
### Server Level (Lucee Administrator)
62
54
63
-
Under "Settings > Scope", set "Local scope mode" to either "Modern" or "Classic".
55
+
Under "Settings > Scope", set "Local scope mode" to "Modern" or "Classic".
64
56
65
-
### 2. Server Configuration (.CFConfig.json)
57
+
### Server Configuration (.CFConfig.json)
66
58
67
59
```json
68
60
{
69
61
"localScopeMode": "modern"
70
62
}
71
63
```
72
64
73
-
Or:
74
-
75
-
```json
76
-
{
77
-
"localScopeMode": "classic"
78
-
}
79
-
```
80
-
81
-
### 3. Application Level (Application.cfc)
65
+
### Application Level (Application.cfc)
82
66
83
67
```cfml
84
68
this.localMode = "modern"; // or "classic"
85
69
```
86
70
87
-
### 4. Function Level
71
+
### Function Level
88
72
89
73
```cfml
90
74
function test() localMode="modern" {
@@ -94,29 +78,20 @@ function test() localMode="modern" {
94
78
95
79
## Migration Strategy: Using Cascading Write Logging
96
80
97
-
Switching directly to Modern mode may break existing applications that rely on Classic behavior. A safer approach is to:
81
+
Switching directly to Modern mode may break existing applications. A safer approach:
98
82
99
-
1. Enable variable scope cascading write logging
100
-
2.Identify and fix all occurrences of unscoped variables
83
+
1. Enable cascading write logging
84
+
2.Fix all unscoped variable occurrences
101
85
3. Switch to Modern mode
102
86
103
87
### Step 1: Enable Cascading Write Logging
104
88
105
-
Set the following environment variables or system properties (This setting only applies to Lucee 6.2.1.82 and above):
Variable Scope Cascading Write Detected: The variable [token] is being implicitly written to the variables scope at [MyComponent.cfc:42]. This occurs when no explicit scope (such as local, arguments, or variables) is specified in the assignment.
137
112
```
138
113
139
-
For each occurrence, decide whether to:
114
+
For each occurrence, add explicit scope:
140
115
141
-
1.**Add explicit `variables` scope** (if the variable should remain in the component's variables scope):
142
-
143
-
```cfml
144
-
variables.token = createUUID();
145
-
```
146
-
147
-
2.**Add explicit `local` scope** (if the variable should be function-local):
148
-
149
-
```cfml
150
-
local.token = createUUID();
151
-
```
116
+
-`variables.token = createUUID();` - if it should remain component-level
117
+
-`local.token = createUUID();` - if it should be function-local
152
118
153
119
### Common Patterns Requiring Attention
154
120
155
121
#### Component Properties
156
122
157
-
Properties meant to be stored at the component level need an explicit variables scope:
123
+
Properties stored at the component level need explicit `variables` scope:
158
124
159
125
```cfml
160
126
// Before
@@ -170,7 +136,7 @@ function init(datasourceName) {
170
136
171
137
#### Local Counters and Temporary Variables
172
138
173
-
Variables that should be local to a function call:
139
+
Variables local to a function call:
174
140
175
141
```cfml
176
142
// Before
@@ -196,31 +162,14 @@ function processItems(items) {
196
162
197
163
### Step 3: Test Thoroughly
198
164
199
-
After updating your code:
200
-
201
165
1. Test your application thoroughly
202
-
2. Verify that all functionality works correctly
203
-
3.Look for unexpected behaviors or errors
204
-
4.Make sure you no longer get any log entries
166
+
2. Verify all functionality works correctly
167
+
3.Check for unexpected behaviors or errors
168
+
4.Ensure no more log entries appear
205
169
206
170
### Step 4: Disable Logging and Switch to Modern Mode
207
171
208
-
Once all code has been updated and tested:
209
-
210
-
1. Disable the cascading write logging by removing the environment variables or system properties:
211
-
212
-
```
213
-
# Remove environment variables
214
-
unset LUCEE_CASCADING_WRITE_TO_VARIABLES_LOG
215
-
unset LUCEE_CASCADING_WRITE_TO_VARIABLES_LOGLEVEL
216
-
217
-
# Or remove system properties from startup configuration
218
-
# -Dlucee.cascading.write.to.variables.log
219
-
# -Dlucee.cascading.write.to.variables.loglevel
220
-
```
221
-
222
-
2. Switch to Modern mode at your preferred configuration level (server, application, or function).
223
-
224
-
## Conclusion
172
+
Once all code is updated and tested:
225
173
226
-
Migrating to Modern mode improves thread safety and code predictability, but requires careful examination of existing code. Using cascading write logging helps identify potential issues before they become problems, allowing for a smooth transition.
174
+
1. Remove the environment variables or system properties
175
+
2. Switch to Modern mode at your preferred configuration level
0 commit comments