Magento 2 debug layout xml

/etc/events.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"></event>
<event name="layout_generate_blocks_after">
    <observer name="layout_generate_blocks_after" instance="Module\Wishlist\Observer\Layout" />
</event>
</config>

Observer

<?php

/** * Create "Layout.php" at onlinecode/Dev/Model/Layout.php */

namespace Module\Wishlist\Observer;

use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;

class Layout implements ObserverInterface
{
    protected $set_logger;
    public function __construct(\Psr\Log\LoggerInterface $logger_cons)
    {
        $this->set_logger = $logger_cons;
    }
    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $get_xml = $observer->getEvent()->getLayout()->getXmlString();
        $this->set_logger->debug($get_xml);
        $get_writer = new \Zend_Log_Writer_Stream(BP . '/var/log/layout_block.xml');
        $get_logger = new \Zend_Log();
        $get_logger->addWriter($get_writer);
        $get_logger->info($get_xml);
        return $this;
    }
}