silverstripe-framework/_config/logging.yml

75 lines
2.6 KiB
YAML
Raw Normal View History

---
Name: logging
---
# Core error logging is built up of a chain containing:
# - A top level \ErrorHandler which registers the error service
# - A \Logger which acts as the error service
# - A \HandlerInterface which handles errors for the logger
# - One or more \FormatterInterface which format errors for the handler
#
# Logging for use outside of core error handling also uses the same implementations,
# but is available without the HandlerInterfaces attached
SilverStripe\Core\Injector\Injector:
SilverStripe\Logging\ErrorHandler:
class: SilverStripe\Logging\MonologErrorHandler
calls:
2018-07-04 02:11:56 +02:00
pushDefaultLogger: [ pushLogger, [ '%$Psr\Log\LoggerInterface' ] ]
pushErrorHandler: [ pushLogger, [ '%$Psr\Log\LoggerInterface.errorhandler' ] ]
# Default implementation for use as a standard logger. Up to developers to attach their own
# handlers
Psr\Log\LoggerInterface:
type: singleton
class: Monolog\Logger
constructor:
- "error-log"
# Core error handling
Psr\Log\LoggerInterface.errorhandler:
type: singleton
class: Monolog\Logger
constructor:
- "error-handler"
calls:
2017-07-21 12:17:18 +02:00
pushDisplayErrorHandler: [ pushHandler, [ '%$Monolog\Handler\HandlerInterface' ] ]
---
Name: loggingformatters
---
SilverStripe\Core\Injector\Injector:
# Display detailed information on an error
Monolog\Formatter\FormatterInterface.detailed:
class: SilverStripe\Logging\DetailedErrorFormatter
# Display friendly error messages and suppresses possible disclosure of dev configuration
Monolog\Formatter\FormatterInterface.friendly:
class: SilverStripe\Logging\DebugViewFriendlyErrorFormatter
properties:
Title: "There has been an error"
Body: "The website server has not been able to respond to your request"
---
Name: dev-logging
Only:
environment: dev
---
# Dev handler outputs detailed information including notices
SilverStripe\Core\Injector\Injector:
Monolog\Handler\HandlerInterface:
class: SilverStripe\Logging\ErrorOutputHandler
constructor:
- "notice"
properties:
2017-07-21 12:17:18 +02:00
DefaultFormatter: '%$Monolog\Formatter\FormatterInterface.detailed'
---
Name: live-logging
Except:
environment: dev
---
# Live handler outputs user-friendly error details, and ignores notices
# CLI errors still show full details
SilverStripe\Core\Injector\Injector:
Monolog\Handler\HandlerInterface:
class: SilverStripe\Logging\ErrorOutputHandler
constructor:
- "error"
properties:
2017-07-21 12:17:18 +02:00
DefaultFormatter: '%$Monolog\Formatter\FormatterInterface.friendly'
CLIFormatter: '%$Monolog\Formatter\FormatterInterface.detailed'