From 4ab83de221f40ec219f3c5b1f1b9871ac604e16d Mon Sep 17 00:00:00 2001 From: Shai Amsalem Date: Wed, 26 Jul 2017 09:41:42 +0300 Subject: [PATCH] Added Readme file and changed the name of the serviceName param to be type --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++ src/AppenderLogzIo.php | 14 ++++++------- 2 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..b1f2db7 --- /dev/null +++ b/README.md @@ -0,0 +1,46 @@ +# Log4Php LogzIo Appender + +[Logz.Io](https://logz.io/) appender for [log4php](https://logging.apache.org/log4php/). +The appender uses tcp socket to send the event to logz.io + +## How to configure the appender + +example of log4php configuration file using the appender: +``` + + + + + + + + + + + + +``` + +you can get more information about the type parameter in [Logz.Io](https://support.logz.io/hc/en-us/sections/202356425-Supported-Log-Types) + +## How to consume the appender using Composer +To import the package using [Composer](https://getcomposer.org/) you need to define the repository in your composer.json file. + +example composer.json file: +``` + { + "config": { + "vendor-dir": "empty-theme/composer-vendor", + }, + "require": { + "apache/log4php": "^2.3", + "soluto/log4phpLogzIoAppender": "dev-master" + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/Soluto/Log4PhpLogzIoAppender.git" + } + ] + } +``` \ No newline at end of file diff --git a/src/AppenderLogzIo.php b/src/AppenderLogzIo.php index 3f74a11..e5d8b42 100644 --- a/src/AppenderLogzIo.php +++ b/src/AppenderLogzIo.php @@ -8,7 +8,7 @@ class AppenderLogzIo extends \LoggerAppender { protected $host = ""; protected $port = ""; - protected $serviceName = ""; + protected $type = ""; protected $logzAccountToken = ""; public function append(\LoggerLoggingEvent $event) { @@ -18,7 +18,7 @@ public function append(\LoggerLoggingEvent $event) { $throwable = $event->getThrowableInformation() ? $this->parseThrowable($event->getThrowableInformation()->getThrowable()) : null; $level = strtolower($event->getLevel()->toString()); - $messageEventToSend = new LogzIoLogEventInfo($this->logzAccountToken, $message, $logTimestamp,$level,$throwable, $this->serviceName); + $messageEventToSend = new LogzIoLogEventInfo($this->logzAccountToken, $message, $logTimestamp,$level,$throwable, $this->type); $this->writeEvent($messageEventToSend); } catch(\Exception $e){ @@ -75,13 +75,13 @@ public function setPort($port) { $this->port = $port; } - public function setServiceName($type) { - $this->serviceName = $type; + public function setType($type) { + $this->type = $type; } - public function getServiceName($type) { - if (empty($this->serviceName)) return "json"; - return $this->serviceName; + public function getType($type) { + if (empty($this->type)) return "json"; + return $this->type; } public function setLogzAccountToken($token) {