Download the PHP package simplecomplex/json-log without Composer
On this page you can find all versions of the php package simplecomplex/json-log. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download simplecomplex/json-log
More information about simplecomplex/json-log
Files in simplecomplex/json-log
Package json-log
Short Description PSR-3 logger which files events as JSON.
License MIT
Homepage https://github.com/simplecomplex/php-jsonlog
Informations about the package json-log
JsonLog
PSR-3 logger which files events as JSON.
Columns
Columns are configuration-wise split in groups of event-, request- and site-specific items.
For every column there's a method and a JSON bucket name (this lists the bucket names).
Several columns get skipped if their equivalent method returns empty string (that's the un-bold items).
Some column's must be set via the PSR-3 logger methods' argument.
All column values are string, except the code column.
Event
- message
- @timestamp: ISO-8601
- message_id: fairly random ID, using site ID as salt
- correlation_id: set via
- subtype: set via , default
- level:
- code: integer, set via ; default
- exception: PHP throwable, via ; becomes class name
- trunc:
- user: set via , or override in extending class
- session: set via , override in extending class
Request
- method: HTTP request method; if in CLI mode
- request_uri: HTTP request URI; console arguments if in CLI mode
- referer: HTTP referrer (sanitized)
- client_ip: remote address, filtered for _reverse_proxyaddresses
- useragent: sanitized
Site
- type: type setting; default
- host: or empty
- site_id: siteid setting
- canonical: canonical setting
- tags: tags setting
Settings
Are set via 'global' SimpleComplex Config, section .
The simplest approach to that is to use environment variables, like
.
constructor uses environment variables as fallback.
- (int) threshold: less severe events are skipped (not logged); default (~)
- (str) siteid: defaults to name of directory above document root
- (str) path: default /php-jsonlog
- (int) truncate (Kb): truncate message so that event JSON doesn't exceed that length; default
- (str) reverse_proxy_addresses: comma-separated list of IP addresses; default empty
- (str) type: default
- (str) canonical: site identifier across multiple instances; default empty
- (str) tags: comma-separated list; default empty
- (str) reverse_proxy_header: default
- (str) file_time: set to empty or to write to the same log file forever; default
- (str) format: ; is not valid JSON, but easier on the eyes
Recommended settings
All environments
- siteid: use something more meaningful than the default
- truncate: way higher, to like , if your system generates giant dumps or traces
Prod environment
- reverse_proxy_addresses: look out for proxy servers
Dev/test environment
- threshold: (~)
- path: make it closer to home if no log extractor (like Kibana+ElasticSearch) running
- format: if no log extractor running
CLI commands
Dependency injection container ID: logger
Recommendation: access (and thus instantiate) JsonLog via DI container ID 'logger'.
See SimpleComplex Utils .
Requirements
- PHP >=7.0
- PSR-3 Log
- SimpleComplex Utils
Suggestions
All versions of json-log with dependencies
psr/log Version ^1.0
simplecomplex/utils Version ^1.8 || ^2.0 || dev-develop