Method
Description
struct getProperties()
Get the entire properties struct.
void setProperties(struct properties)
Override all properties with a new properties struct.
any getProperty(string property)
Get a property.
void setProperty(string property, any value)
Set a property.
boolean propertyExists(string property)
Checks if a property exists.
Method
Description
boolean isInitialized()
Returns true if the appender has been initialized.
string getName()
Get the name of the appender
string getHash()
Get the appender's unique hash id
string severityToString(numeric severity)
Transforms a severity integer to it's human readable form
Method
Description
any getCustomLayout()
Get the custom layout object if defined.
boolean hasCustomLayout()
Checks if the custom layout object is defined in this appender.
In order for an appender to deal with custom layouts, you must use the layout methods when preparing to log your messages. Below is a simple example from the console appender of how to do this:
As you can see, all you need to do is have an if
statement that checks whether the appender has a custom layout or not and then assign the return of the layout as your message to log.
You can programmatically register appenders at runtime by using the registerAppender()
function exposed in the LogBox object. Here is the function API:
Info Please note that registering dynamic appenders at runtime is tricky as some objecs might already have references to some appenders. We recommend registering appenders at configuration load or when the application starts up.
Every Appender has access to the following public variables:
In order to create your own appenders, you will have to create a cfc that extends logbox.system.logging.AbstractAppender
and implement the following methods:
init()
The signature of the init method is the following:
As you can see each appender receives a name
, a structure of properties
, an optional layout
class, and an optional levelMin
and levelMax
severity levels. The properties
and layout
are both optional, but you must call the super.init( argumentCollection = arguments )
method in order to have full ok operation on the appender. You can then do your own constructor as you see fit. Here is an example:
logMessage()
The signature of the logMessage
method is the following:
As you can see it is a very simple method that receives a LogBox logging event object. This object keeps track of the following properties with its appropriate getters and setters:
timestamp
category
message
severity
extraInfo
You can then use this logging event object to log to whatever destination you want. Here is a snippet from our scope appender:
onRegistration()
& onUnregistration()
Finally, both the onRegistration
and onUnregistration
methods have to be void methods with no arguments.
These are great for starting or stopping your appenders if they so need to. Here is a sample from our socket appender:
Property
Description
this.logLevels
A reference to the logbox.system.logging.LogLevels
class.
Method
Description
init()
Your constructor. Make sure to call super.init( argumentCollection=arguments );
logMessage()
The method that is called when a message is received.
onRegistration()
An interceptor that fires when the appender gets created and initialized. It can be used for preparing the appender for operation.
onUnRegistration()
An interceptor that fires when the appender is removed from a logger.