A log4php appender build as wrapper for maknz/slack package

0.2.0 2017-07-16 22:50 UTC



Dependency Status Latest Stable Version Total Downloads Latest Unstable Version License

Monthly Downloads Daily Downloads

Code Climate Code Climate


Master Branch

Build Status StyleCI codecov

Develop Branch

Build Status StyleCI codecov


This package allows you to use Slack for PHP easily and elegantly in your app as an log4php appender. Read the instructions below to get it set up.


PHP >= 5.5 || >= 7


You can install the package using the Composer package manager. You can install it by running this command in your project root:

composer require fahl-design/log4php-slack-appender

Then create an incoming webhook for each Slack team you'd like to send messages to. You'll need the webhook URL(s) in order to configure this package.

After you got your hook url add it as endpoint to your configuration

XML appender config example

    <log4php:configuration xmlns:log4php="http://logging.apache.org/log4php/" threshold="all">
        <appender name="appender_slack" class="LoggerAppenderSlack">
            <!-- get endpoint url from https://my.slack.com/services/new/incoming-webhook -->
            <param name="endpoint" value="https://hooks.slack.com/services/XXXXXXXXXXXXXXX/XXXXXXXXXXXXXXX/XXXXXXXXXXXXXXX" />
            <param name="channel" value="#yourChannel" />
            <param name="username" value="Log4php" />
            <!-- Url or emoji-->
            <param name="icon" value=":do_not_litter:" />
            <!-- flag to allow markdown (default 1) -->
            <param name="allowMarkdown" value="1" />
            <!-- flag to send log message as slack attachment (default 1) -->
            <param name="asAttachment" value="1" />
        <logger name="myLogger">
            <appender_ref ref="appender_slack" />

php (config.php) appender config example

    return [
        'rootLogger' => [
            'appenders' => ['default'],
        'myLogger' => [
            'appenders' => ['default'],
        'appenders' => [
            'default' => [
                'class' => 'LoggerAppenderSlack',
                'params' => [
                    'endpoint' => 'https://hooks.slack.com/services/XXXXXXXXXXXXXXX/XXXXXXXXXXXXXXX/XXXXXXXXXXXXXXX',
                    'channel' => '#yourChannel',
                    'username' => 'log4php',
                    'icon' => ':ghost:', // emoji or an icon url


Check example (src/examples)

require_once __DIR__.'/../../../vendor/autoload.php';


$logger = Logger::getLogger('myLogger');