Created
July 5, 2019 00:05
-
-
Save InFog/002402866979b89ee4d6428adeb6d916 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include __DIR__ . "/vendor/autoload.php"; | |
use Elastica\Client; | |
use Monolog\Formatter\LogstashFormatter; | |
use Monolog\Handler\ElasticSearchHandler; | |
use Monolog\Logger; | |
$logger = new Logger("MyApp"); | |
$client = new Client([ | |
'host' => 'localhost', | |
'port' => 9200, | |
]); | |
$handler = new ElasticSearchHandler($client); | |
$logger->pushHandler($handler); | |
$logger->info("Running the app"); | |
$n = rand(0, 10); | |
if ($n > 9) { | |
$logger->error("This is an error!!!"); | |
} else { | |
$logger->warn("Something happened"); | |
} | |
$logger->info("Finished running the app"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment