Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Configuration of LogWriters

The configuraton of log writers can be either done in the application.ini / installation.ini or hardcoded in PHP.

Code Block
titleCurrent writer configuration in application.ini
linenumberstrue
resources.ZfExtended_Resource_Logger.writer.default.type = 'ErrorLog'
resources.ZfExtended_Resource_Logger.writer.default.filter[] = "level <= debug" ; → warn logs from fatal to debug

; Test config:
resources.ZfExtended_Resource_Logger.writer.mail.type = 'DirectMail'
; via the formatter define what the user gets: full debug content, or only notice and so on.
resources.ZfExtended_Resource_Logger.writer.mail.filter[] = "level <= error" ; → warn logs from fatal till error
resources.ZfExtended_Resource_Logger.writer.sender = 'sysadmin@example.com' ; → should be overwritten with useful values in installation.ini
resources.ZfExtended_Resource_Logger.writer.mail.receiver[] = 'sysadmin@example.com' ; → should be overwritten with useful values in installation.ini
resources.ZfExtended_Resource_Logger.writer.mail.receiver[] = 'other-important-person@example.com' ; → should be overwritten with useful values in installation.ini

resources.ZfExtended_Resource_Logger.writer.mail.type = 'Database'
; via the formatter define what the user gets: full debug content, or only notice and so on.
resources.ZfExtended_Resource_Logger.writer.mail.filter[] = "level <= debug" ; logs from fatal to debug
Code Block
titletask log writer config in application/modules/editor/configs/module.ini
resources.ZfExtended_Resource_Logger.writer.tasklog.type = 'editor_Logger_TaskWriter'
resources.ZfExtended_Resource_Logger.writer.tasklog.filter[] = "level <= warn" ; logs only from fatal to warning

; example for an additional filter to log from fatal to debug for events with an domain starting with "core.foo.bar"
resources.ZfExtended_Resource_Logger.writer.tasklog.filter[] = "level <= debug; domain ^= core.foo.bar" 

; The TaskWriter is a editor specific writer, it logs only events containing information about a task. The events are logged in a dedicated table, accessable via the frontend. Only warnings or events more severe as warnings are written to the task log. So no notices about tasks are additionally logged.
Code Block
languagephp
titleIn PHP just add new writters to the wanted logger instance
// use the default logger instance:
$logger = Zend_Registry::get('logger');
$logger->addWriter('name', $writerInstance);

Filtering

Each writer can have an list of filter rules. See the above module.ini example. The filter rules are connected via "or", that means one of the filter rules must be valid in order that an event  is logged.

Code Block
titletask log writer config in application/modules/editor/configs/module.ini
resources.ZfExtended_Resource_Logger.writer.tasklog.filter[] = "level <= warn" ; first filter rule
resources.ZfExtended_Resource_Logger.writer.tasklog.filter[] = "level <= debug; domain ^= core.foo.bar" ; second filter rule

Each filter rule is it self, a semicolon separated list of expressions. All expressions of one rule are connected via "and", so all expressions must be evaluated to true in order that the rule is valid.

An expression consists of a keyword, an operator and a value, for example: "level <= warn". Each keyword can be used multiple times, so "level >= warn; level <= trace" would also be possible.

Warning

They keyword must be always the first operand! So "warn <= level" would give an error since it can not be parsed.

In the following table a list of valid keywords and operands is listed:

...

Is used to compare with the log levels as defined at the top of this page.

The second operand must be a valid log level: "fatal", "error", "warn" etc.
Since internally the levels are integers, only numeric operators are usable here.

Example: given FATAL(1), configured "level <= WARN(4)" the event is filtered, since level 1 (fatal) is lesser then level 4 (warn)

...

=

...

The domain (origin) of the event must be matched completely.

...

documentation about the configuration of the LogWriters is here.

Logging Database Tables

Currently there are two database tables receiving events:

...