diff --git a/CHANGELOG-4.md b/CHANGELOG-4.md
index 7002d648..3dbce9d0 100644
--- a/CHANGELOG-4.md
+++ b/CHANGELOG-4.md
@@ -10,6 +10,7 @@
* Remove `excluded_404s` option, use `excluded_http_codes` instead
* Remove `console_formater_options` option, use `console_formatter_options` instead
* Remove `elasticsearch` type, use `elastica` or `elastic_search` instead
+* Remove `mongo` type, use `mongodb` instead
* Remove `sentry` and `raven` types, use a `service` type with [`sentry/sentry-symfony`](https://docs.sentryio/platforms/php/guides/symfony/logs/) instead
* Remove `DebugHandlerPass`
* Remove support for the `DebugHandler`
diff --git a/config/schema/monolog-1.0.xsd b/config/schema/monolog-1.0.xsd
index 0c4c0f84..a444ce49 100644
--- a/config/schema/monolog-1.0.xsd
+++ b/config/schema/monolog-1.0.xsd
@@ -20,7 +20,6 @@
-
@@ -148,16 +147,6 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php
index b1afbcd2..a51a2dd6 100644
--- a/src/DependencyInjection/Configuration.php
+++ b/src/DependencyInjection/Configuration.php
@@ -79,18 +79,6 @@
* - [filename_format]: string, defaults to '{filename}-{date}'
* - [date_format]: string, defaults to 'Y-m-d'
*
- * - mongo:
- * - mongo:
- * - id: optional if host is given
- * - host: database host name, optional if id is given
- * - [port]: defaults to 27017
- * - [user]: database user name
- * - pass: mandatory only if user is present
- * - [database]: defaults to monolog
- * - [collection]: defaults to logs
- * - [level]: level name or int value, defaults to DEBUG
- * - [bubble]: bool, defaults to true
- *
* - mongodb:
* - mongodb:
* - id: optional if uri is given
@@ -584,7 +572,6 @@ public function getConfigTreeBuilder(): TreeBuilder
->end();
$this->addGelfSection($handlerNode);
- $this->addMongoSection($handlerNode);
$this->addMongoDBSection($handlerNode);
$this->addElasticsearchSection($handlerNode);
$this->addRedisSection($handlerNode);
@@ -742,46 +729,6 @@ private function addGelfSection(ArrayNodeDefinition $handlerNode): void
;
}
- private function addMongoSection(ArrayNodeDefinition $handlerNode): void
- {
- $handlerNode
- ->children()
- ->arrayNode('mongo')
- ->canBeUnset()
- ->beforeNormalization()
- ->ifString()
- ->then(function ($v) { return ['id' => $v]; })
- ->end()
- ->children()
- ->scalarNode('id')->end()
- ->scalarNode('host')->end()
- ->scalarNode('port')->defaultValue(27017)->end()
- ->scalarNode('user')->end()
- ->scalarNode('pass')->end()
- ->scalarNode('database')->defaultValue('monolog')->end()
- ->scalarNode('collection')->defaultValue('logs')->end()
- ->end()
- ->validate()
- ->ifTrue(function ($v) {
- return !isset($v['id']) && !isset($v['host']);
- })
- ->thenInvalid('The "mongo" handler configuration requires either a service "id" or a connection "host".')
- ->end()
- ->validate()
- ->ifTrue(function ($v) {
- return isset($v['user']) && !isset($v['pass']);
- })
- ->thenInvalid('If you set user, you must provide a password.')
- ->end()
- ->end()
- ->end()
- ->validate()
- ->ifTrue(function ($v) { return 'mongo' === $v['type'] && !isset($v['mongo']); })
- ->thenInvalid('The "mongo" configuration has to be specified to use a "mongo" handler type.')
- ->end()
- ;
- }
-
private function addMongoDBSection(ArrayNodeDefinition $handlerNode)
{
$handlerNode
diff --git a/src/DependencyInjection/MonologExtension.php b/src/DependencyInjection/MonologExtension.php
index 7e0d1bf2..bc893565 100644
--- a/src/DependencyInjection/MonologExtension.php
+++ b/src/DependencyInjection/MonologExtension.php
@@ -231,39 +231,6 @@ private function buildHandler(ContainerBuilder $container, string $name, array $
]);
break;
- case 'mongo':
- trigger_deprecation('symfony/monolog-bundle', '3.11', 'The "mongo" handler type is deprecated in MonologBundle since version 3.11.0, use the "mongodb" type instead.');
-
- if (!class_exists(\MongoDB\Client::class)) {
- throw new \RuntimeException('The "mongo" handler requires the mongodb/mongodb package to be installed.');
- }
-
- if (isset($handler['mongo']['id'])) {
- $client = new Reference($handler['mongo']['id']);
- } else {
- $server = 'mongodb://';
-
- if (isset($handler['mongo']['user'])) {
- $server .= $handler['mongo']['user'].':'.$handler['mongo']['pass'].'@';
- }
-
- $server .= $handler['mongo']['host'].':'.$handler['mongo']['port'];
-
- $client = new Definition(\MongoDB\Client::class, [
- $server,
- ['appname' => 'monolog-bundle'],
- ]);
- }
-
- $definition->setArguments([
- $client,
- $handler['mongo']['database'],
- $handler['mongo']['collection'],
- $handler['level'],
- $handler['bubble'],
- ]);
- break;
-
case 'mongodb':
if (!class_exists(\MongoDB\Client::class)) {
throw new \RuntimeException('The "mongodb" handler requires the mongodb/mongodb package to be installed.');
@@ -302,10 +269,6 @@ private function buildHandler(ContainerBuilder $container, string $name, array $
}
break;
- case 'elasticsearch':
- trigger_deprecation('symfony/monolog-bundle', '3.8', 'The "elasticsearch" handler type is deprecated in MonologBundle since version 3.8.0, use the "elastica" type instead, or switch to the official Elastic client using the "elastic_search" type.');
- // no break
-
case 'elastica':
case 'elastic_search':
if (isset($handler['elasticsearch']['id'])) {
@@ -859,7 +822,7 @@ private function getHandlerClassByType(string $handlerType): string
'whatfailuregroup' => \Monolog\Handler\WhatFailureGroupHandler::class,
'fingers_crossed' => \Monolog\Handler\FingersCrossedHandler::class,
'filter' => \Monolog\Handler\FilterHandler::class,
- 'mongo','mongodb' => \Monolog\Handler\MongoDBHandler::class,
+ 'mongodb' => \Monolog\Handler\MongoDBHandler::class,
'telegram' => \Monolog\Handler\TelegramBotHandler::class,
'server_log' => \Symfony\Bridge\Monolog\Handler\ServerLogHandler::class,
'redis', 'predis' => \Monolog\Handler\RedisHandler::class,
diff --git a/tests/DependencyInjection/MonologExtensionTest.php b/tests/DependencyInjection/MonologExtensionTest.php
index 15fc7a3a..58f0fa69 100644
--- a/tests/DependencyInjection/MonologExtensionTest.php
+++ b/tests/DependencyInjection/MonologExtensionTest.php
@@ -18,8 +18,6 @@
use Monolog\Handler\RollbarHandler;
use Monolog\Processor\UidProcessor;
use PHPUnit\Framework\Attributes\DataProvider;
-use PHPUnit\Framework\Attributes\Group;
-use PHPUnit\Framework\Attributes\IgnoreDeprecations;
use Symfony\Bundle\MonologBundle\DependencyInjection\Compiler\LoggerChannelPass;
use Symfony\Bundle\MonologBundle\DependencyInjection\MonologExtension;
use Symfony\Bundle\MonologBundle\Tests\DependencyInjection\Fixtures\AsMonologProcessor\FooProcessorWithPriority;
@@ -556,84 +554,6 @@ public function testElasticsearchAndElasticaHandlers()
$this->assertSame(['hosts' => ['es:9200'], 'transport' => 'Http'], $elasticaClient->getArgument(0));
}
- #[Group('legacy')]
- #[IgnoreDeprecations]
- public function testMongo()
- {
- if (!class_exists('MongoDB\Client')) {
- $this->markTestSkipped('mongodb/mongodb is not installed.');
- }
-
- // $this->expectDeprecation('Since symfony/monolog-bundle 3.11: The "mongo" handler type is deprecated in MonologBundle since version 3.11.0, use the "mongodb" type instead.');
-
- $container = new ContainerBuilder();
- $container->setDefinition('mongodb.client', new Definition('MongoDB\Client'));
-
- $config = [[
- 'handlers' => [
- 'mongo_with_id' => [
- 'type' => 'mongo',
- 'mongo' => ['id' => 'mongodb.client'],
- ],
- 'mongo_with_string_id' => [
- 'type' => 'mongo',
- 'mongo' => 'mongodb.client',
- ],
- 'mongo_with_host' => [
- 'type' => 'mongo',
- 'mongo' => [
- 'host' => 'localhost',
- 'port' => '27018',
- 'user' => 'username',
- 'pass' => 'password',
- 'database' => 'db',
- 'collection' => 'coll',
- ],
- ],
- 'mongo_with_host_and_default_args' => [
- 'type' => 'mongo',
- 'mongo' => [
- 'host' => 'localhost',
- ],
- ],
- ],
- ]];
-
- $extension = new MonologExtension();
- $extension->load($config, $container);
-
- $this->assertTrue($container->hasDefinition('monolog.handler.mongo_with_id'));
- $this->assertTrue($container->hasDefinition('monolog.handler.mongo_with_string_id'));
- $this->assertTrue($container->hasDefinition('monolog.handler.mongo_with_host'));
- $this->assertTrue($container->hasDefinition('monolog.handler.mongo_with_host_and_default_args'));
-
- // MongoDB handler should receive the mongodb.client as first argument
- $handler = $container->getDefinition('monolog.handler.mongo_with_id');
- $this->assertDICDefinitionClass($handler, MongoDBHandler::class);
- $this->assertDICConstructorArguments($handler, [new Reference('mongodb.client'), 'monolog', 'logs', 'DEBUG', true]);
-
- // MongoDB handler should receive the mongodb.client as first argument
- $handler = $container->getDefinition('monolog.handler.mongo_with_string_id');
- $this->assertDICDefinitionClass($handler, MongoDBHandler::class);
- $this->assertDICConstructorArguments($handler, [new Reference('mongodb.client'), 'monolog', 'logs', 'DEBUG', true]);
-
- // MongoDB handler with host and arguments
- $handler = $container->getDefinition('monolog.handler.mongo_with_host');
- $this->assertDICDefinitionClass($handler, MongoDBHandler::class);
- $client = $handler->getArgument(0);
- $this->assertDICDefinitionClass($client, 'MongoDB\Client');
- $this->assertDICConstructorArguments($client, ['mongodb://username:password@localhost:27018', ['appname' => 'monolog-bundle']]);
- $this->assertDICConstructorArguments($handler, [$client, 'db', 'coll', 'DEBUG', true]);
-
- // MongoDB handler with host and default arguments
- $handler = $container->getDefinition('monolog.handler.mongo_with_host_and_default_args');
- $this->assertDICDefinitionClass($handler, MongoDBHandler::class);
- $client = $handler->getArgument(0);
- $this->assertDICDefinitionClass($client, 'MongoDB\Client');
- $this->assertDICConstructorArguments($client, ['mongodb://localhost:27017', ['appname' => 'monolog-bundle']]);
- $this->assertDICConstructorArguments($handler, [$client, 'monolog', 'logs', 'DEBUG', true]);
- }
-
public function testMongoDB()
{
if (!class_exists('MongoDB\Client')) {