FrameworkLogging and ApplicationLogging
The FrameworkLogging and ApplicationLogging facilities control how your components, and Granitic’s built-in components, log messages by importance/severity.
Logging in Granitic is discussed in detail in a dedicated section of the reference manual and as such this page is limited to explaining the configuration options available.
Enabling
FrameworkLogging and ApplicationLogging are enabled by default. They can be disabled by setting Facilities.FrameworkLogging
and/or Facilities.ApplicationLogging
to false
in your configuration.
Disabling logging causes Granitic to inject ‘null’ loggers into code that expects an instance of logging.Logger. This means your code does not need to worry if logging is disabled or not.
Configuration
The default configuration for this facility can be found in the Granitic source under facility/config/logging.json
and is:
{
"LogWriting": {
"EnableConsoleLogging": true,
"EnableFileLogging": false,
"File": {
"LogPath": "./granitic.log",
"BufferSize": 50
},
"Format": {
"Entry": "TEXT",
"UtcTimes": true,
"Unset": "-",
"JSON": {
"Prefix": "",
"Fields": [
["Timestamp", "TIMESTAMP", "02/Jan/2006:15:04:05 Z0700"],
["Level", "LEVEL"],
["Source", "COMPONENT_NAME"],
["Message", "MESSAGE"]
],
"Suffix": "\n"
}
}
},
"FrameworkLogger":{
"GlobalLogLevel": "INFO"
},
"ApplicationLogger":{
"GlobalLogLevel": "INFO"
}
}
Controlling global and per-component log-levels
This is explained in the log-levels section section of the reference manual.
Controlling the location and format of log files
This is explained in the formatting and location section of the reference manual.
Switching between text and JSON logging
This is explained in the formatting and location section of the reference manual.
Component reference
The following components are created when both facilities are enabled
Name | Type |
---|---|
grncApplicationLoggingManager | logging.ComponentLoggerManager |
grncFrameworkLoggingManager | logging.ComponentLoggerManager |
Next: JSON Web Services
Prev: HTTP Server