Write message in system.log file -

\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->info('log message');

Print log in debug.log file

\Magento\Framework\App\ObjectManager::getInstance()->get('Psr\Log\LoggerInterface')->log(100,print_r($data,true));

OR

private $logger;

public function __construct(\Psr\Log\LoggerInterface $logger)

{

$this->logger = $logger;

}

public function mylogwritefunction()

{

try

{ /* Some logic that could throw an Exception */

} catch (\Exception $e)

{ $this->logger->critical($e->getMessage());

}

}