Skip to content
This repository has been archived by the owner on Aug 5, 2021. It is now read-only.

Commit

Permalink
Added Readme file and changed the name of the serviceName param to be…
Browse files Browse the repository at this point in the history
… type
  • Loading branch information
Shayams committed Jul 26, 2017
1 parent 30792b8 commit 4ab83de
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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:
```
<configuration xmlns="http://logging.apache.org/log4php/">
<appender name="logzIoAppender" class="\Soluto\LoggerAppenders\AppenderLogzIo">
<param name="host" value="listener.logz.io" />
<param name="port" value="5050" />
<param name="type" value="MyLogType" />
<param name="logzAccountToken" value="MyToken" />
</appender>
<root>
<level value="WARN" />
<appender_ref ref="logzIoAppender" />
</root>
</configuration>
```

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"
}
]
}
```
14 changes: 7 additions & 7 deletions src/AppenderLogzIo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AppenderLogzIo extends \LoggerAppender {

protected $host = "";
protected $port = "";
protected $serviceName = "";
protected $type = "";
protected $logzAccountToken = "";

public function append(\LoggerLoggingEvent $event) {
Expand All @@ -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){
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4ab83de

Please sign in to comment.