PHPackages                             marco-introini/soap-logger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. marco-introini/soap-logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

marco-introini/soap-logger
==========================

Simple PHP Soap logger

V1.1.0(3y ago)01.3k—0%MITPHPPHP &gt;=8.1

Since Nov 21Pushed 3y ago1 watchersCompare

[ Source](https://github.com/marco-introini/soap-logger)[ Packagist](https://packagist.org/packages/marco-introini/soap-logger)[ RSS](/packages/marco-introini-soap-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (5)Versions (8)Used By (0)

PHP Logger for Soap Web Services
================================

[](#php-logger-for-soap-web-services)

Installation
------------

[](#installation)

Installation is possible using Composer

```
composer require marco-introini/soap-logger

```

Usage
-----

[](#usage)

### Log

[](#log)

The main logger class can be instantiated using the following parameters:

- a monolog handler
- a line formatter
- the name of the Soap service
- the name of the method
- if the request contains soapAction this information will be automatically added to logger

```
$handler = new RotatingFileHandler($_ENV['LOGFILE'], 3,Level::Info);
$formatter = new SplunkLineFormatter(allowInlineLineBreaks: true, quoteReplacement: "");

$soapLogger = new SoapLogger($handler,$formatter,"MyDemoService","demoMethodRead");

$soapLogger->log(file_get_contents('php://input'),Step::FROM_CALLER_TO_SERVICE);
```

### Log SoapServer Request and Response XML

[](#log-soapserver-request-and-response-xml)

This is how to het the Soap envelope for request and response

#### Request

[](#request)

Obtaining request it's very easy:

```
$request = file_get_contents('php://input');
$soapLogger->log(file_get_contents('php://input'),Step::FROM_CALLER_TO_SERVICE);
```

#### Response

[](#response)

Obtaining response it's a bit more difficult. We must catch the output of the handle() method. Look at this example:

```
ob_start();
$server = new SoapServer("mywsdlfile.wsdl", array(
    'classmap' => array(
        'MyMethodResponse' => MyMethodResponse::class,
        'MyMethodRequest' => MyMethodRequest::class
    )
));
$server->addFunction("myMethod");
$server->handle();
$response = ob_get_contents();
ob_end_clean();
$soapLogger->log($response,Step::FROM_SERVICE_TO_CALLER);
echo $response;
```

In the $response variable we have the response XML.

**Important: always remeber to echo the response!**

### Rotation based on file size

[](#rotation-based-on-file-size)

Very often the Soap log are very verbose, so it's useful to have a rotation method for Monolog to log rotation based on file size. This is not possible with plain Monolog. So I write a simple factory to generate a Monolog Handler which can do a log rotation.

The make factory accept these parameters:

- logfile path
- maximum size in bytes
- number of files to rotate (will be kept these number of log-rotation)
- log Level

```
$handler = RotateOnFileSizeHandler::make($_ENV['LOGFILE'],50000000,1,Level::Info);
$formatter = new SplunkLineFormatter(allowInlineLineBreaks: true, quoteReplacement: "");

$soapLogger = new SoapLogger($handler,$formatter,"MyDemoService","myMethod","myCorrelationId");

$soapLogger->log(file_get_contents('php://input'),Step::FROM_CALLER_TO_SERVICE);
```

Using standard Monolog Logger:

```
$handler = RotateOnFileSizeHandler::make($logfile, 1000, 1, Level::Info);

$logger = new Monolog\Logger($logTemp);
$logger->pushHandler($handler);

$logger->log(Level::Info,'log message');
```

Test
----

[](#test)

Tests are created using Pest

```
./vendor/bin/pest

```

License
-------

[](#license)

This project is licensed as Open Source under MIT license

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

7

Last Release

1244d ago

Major Versions

v0.0.5 → v1.0.02022-11-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/01b7629b248c3a25d02c6e302e8441f4cc4b4f05c31fc7d543b72dc0b1eded80?d=identicon)[marco-introini](/maintainers/marco-introini)

---

Top Contributors

[![marco-introini](https://avatars.githubusercontent.com/u/89445565?v=4)](https://github.com/marco-introini "marco-introini (11 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/marco-introini-soap-logger/health.svg)

```
[![Health](https://phpackages.com/badges/marco-introini-soap-logger/health.svg)](https://phpackages.com/packages/marco-introini-soap-logger)
```

###  Alternatives

[bacula-web/bacula-web

The open source web based reporting and monitoring tool for Bacula

1537.5k](/packages/bacula-web-bacula-web)[hamidrezaniazi/pecs

PHP ECS (Elastic Common Schema): Simplify logging with the power of elastic common schema.

3325.5k1](/packages/hamidrezaniazi-pecs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
