1. Go to this page and download the library: Download hisune/log2ck library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hisune / log2ck example snippets
use Hisune\Log2Ck\Manager;
_SEPARATOR . 'config.php'))->run();
return [
'env' => [ // System environment variables
// 'bin' => [
// 'php' => '/usr/bin/php', // Optional configuration, the path to which the php bin file belongs
// ],
'clickhouse' => [ // Required configuration
'dsn' => 'tcp://192.168.37.205:9000',
'username' => 'default',
'password' => '',
'options' => [
'connect_timeout' => 3,
'socket_timeout' => 30,
'tcp_nodelay' => true,
'persistent' => true,
],
'database' => 'logs', // Database name
'table' => 'repo', // Table name
'max_sent_count' => 100, // Insert when there are many pieces of data in a single batch
'max_sent_wait' => 10, // If the number of data items in a single batch is not satisfied, the insertion will be performed at least once in how many seconds
],
// 'worker' => [
// 'cache_path' => '/dev/shm/', // Optional configuration, worker cache directory
// ],
// 'logger' => [
// 'enable' => true, // Optional configuration, whether to record logs
// 'path' => __DIR__ . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR, // Specify the directory where the logs are logged, optional configuration, and need to end with /
// ],
],
'tails' => [
'access' => [ // Key is the log name, corresponding to the name field of clickhouse
'repo' => 'api2', // The name of the project to which the log belongs
'path' => '/mnt/c/access.log', // eg: Log path, fixed file name log
// 'path' => '/mnt/c/access-{date}.log', // eg: Log path, a daily log with a file name, currently only one macro variable {date} is supported. For example, the date format: 2022-02-22
// 'host' => 'host1', // Customize the host name, the default is the server host name if it is not set, which corresponds to the host field of clickhouse
// 'pattern' => '/\[(?P<created_at>.*)\] (?P<logger>\w+).(?P<level>\w+): (?P<message>.*[^ ]+) (?P<context>[^ ]+) (?P<extra>[^ ]+)/', // Optional configuration, if regular processing is not
sh
# Install
composer to the configuration you want
cp vendor/hisune/log2ck/test.config.php config.php
# Create manager
vim manager.php
sh
# Begin execution
php manager.php
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.