Download the PHP package nekonomokochan/php-json-logger without Composer

On this page you can find all versions of the php package nekonomokochan/php-json-logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-json-logger

php-json-logger

Latest Stable Version Total Downloads Latest Unstable Version License Monthly Downloads Daily Downloads composer.lock Build Status Coverage Status

LoggingLibrary for PHP. Output by JSON Format

This Library is mainly intended for use in web applications.

Getting Started

Install composer package

How To Use

Basic usage

It is output as follows.

The unit of process_time is ms(millisecond).

How to change output filepath

Default output filepath is /tmp/php-json-logger-yyyy-mm-dd.log .

If you want to change the output filepath, please set the output filepath to the builder class.

The output filepath is /tmp/test-php-json-logger-yyyy-mm-dd.log .

It is output as follows.

How to Set trace_id

Any value can be set for trace_id.

This will help you when looking for logs you want.

It is output as follows.

How to change logLevel

Please use \Nekonomokochan\PhpJsonLogger\LoggerBuilder::setLogLevel() .

For example, the following code does not output logs.

Because the level is set to CRITICAL.

You can set the following values for logLevel .

These are the same as logLevel defined in Monolog.

How to change channel

Default channel is PhpJsonLogger.

If you want to change the channel, you can change it with the following code.

For example, the output is as follows.

How to change Log Rotation Date

This is the default setting to save logs for 7 days.

If you want to change the log Rotation date, you can change it with the following code.

The following code sets the log retention period to 2 days.

Extend and use \Nekonomokochan\PhpJsonLogger\JsonFormatter

You can make your own \Monolog\Logger using only \Nekonomokochan\PhpJsonLogger\JsonFormatter.

This method is useful when you need \Monolog\Logger in web application framework(e.g. Laravel).

The following is sample code.

It is output to extended-monolog-test-yyyy-mm-dd.log as follows

The following code is necessary to output trace_id and process_time.

The code below is the code necessary to normally display the stack trace with JSON.

To output the stack trace to the log, execute the following code.

Please pay attention to the part $this->formatPhpJsonLoggerErrorsContext($exception, $context).

This is necessary processing to format the error log into JSON and output it.

This is the method implemented in \Nekonomokochan\PhpJsonLogger\ErrorsContextFormat.

It is output to extended-monolog-test-yyyy-mm-dd.log as follows.

If you want to know more detailed usage, please look at php-json-logger/tests/ExtendedMonologTest.php.

Notification To Slack

To send the log to Slack please execute the following code.

This code will be sent to slack if the log level is CRITICAL or higher.

Use in Docker

Please use LoggerBuilder.setUseInDocker in order to use it on Docker.

When setUseInDocker is set to true, no file output is done and the log is output as stdout.

Caution

\Nekonomokochan\PhpJsonLogger\Logger is a subclass that extends \Monolog\Logger

You can use it like \Monolog\Logger.

However, for the following methods, you can pass only classes that extend \Exception or \Error as arguments.

In case of violation, \Nekonomokochan\PhpJsonLogger\Logger will Throw \Nekonomokochan\PhpJsonLogger\InvalidArgumentException

License

MIT


All versions of php-json-logger with dependencies

PHP Build Version
Package Version
Requires php Version ~7.1
monolog/monolog Version ^1.24
ramsey/uuid Version ^3.8
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nekonomokochan/php-json-logger contains the following files

Loading the files please wait ....