Logging
cbElasticsearch comes pre-packaged with two logging appenders which can be configured in your Coldbox application to capture log messages and store them for later search and retrieval. The appenders differ in the manner in which they store data within the elasticsearch index.
  • LogstashAppender - This appender stores its log data in indexes named by the rotation frequency. Log data is never deleted. Instead, new indexes are created at intervals specified by the rotation property, which defaults to "daily" but can be set to "monthly", "weekly" or "hourly".
  • ElasticsearchAppender - This appender stores its log data in a single index, with a specified rotation frequency and period of retention. During rotation, any documents which are older than the specified rotationDays value are purged from the elasticsearch index.
Appenders may be configured in your Coldbox configuration like so:
1
logBox = {
2
// Define Appenders
3
appenders = {
4
console = {
5
class="coldbox.system.logging.appenders.ConsoleAppender"
6
},
7
elasticsearch = {
8
class="cbelasticsearch.models.logging.ElasticsearchAppender",
9
properties = {
10
// the name of the index to store log data in - defaults to logbox
11
"index" : "myapp-logs",
12
// Provide a unique name for the application ( optional ) - useful for filtering shared log indexes
13
"applicationName" : "myapp",
14
// Optional release version
15
"releaseVersion" : "1.0.0",
16
// the number of days to retain logs
17
"rotationDays" : 30,
18
// perform the rotation purge every this number of minutes
19
"rotationFrequency": 5
20
}
21
},
22
logstash = {
23
class="cbelasticsearch.models.logging.LogstashAppender",
24
properties = {
25
// the index prefix to use - prior to the rotational timestamps - defaults to ".logstash-[applicationName]"
26
"index" : "myapp-logs",
27
// Provide a unique name for the application ( optional ) - useful for filtering shared log indexes
28
"applicationName" : "myapp",
29
// Optional release version
30
"releaseVersion" : "1.0.0",
31
// the frequency of index rotation
32
"rotation" : "daily"
33
}
34
}
35
36
},
37
// Root Logger - appends error messages to all appenders
38
root = { levelmax="ERROR", appenders="*" }
39
};
Copied!
For more information on configuring log appenders for your application, see the Coldbox documentation
Last modified 1yr ago
Copy link
Edit on GitHub