4 added 9 characters in body
source | link

In Magento 1, it was common to segment logs into different files (to separate logs for payment methods, etc.). That's as easy as changing the $file parameter of Mage::log.

Magento 2 has changed to use Monolog.

It appears that Monolog (or Magento2's implementation of it) segments all logs for the entire framework to handlers by severity. There are a few handlers that write to file:   

\Magento\Framework\Logger\Handler\Debug, \Magento\Framework\Logger\Handler\Exception, \Magento\Framework\Logger\Handler\System, logging

Logging to respective files in var/logvar/log as in Magento 1.

I could add a handler for a particular severity (IE, write notices to var/log/notice.log). Extend \Magento\Framework\Logger\Handler\Base, and register the handler in di.xml.

This article roughly describes that process: http://semaphoresoftware.kinja.com/how-to-create-a-custom-log-in-magento-2-1704130912

But how do I go about writing all logs (not just one severity) for one class (not all of Magento) to my file of choice?

It looks like I'll have to create my own version of Magento\Framework\Logger\Monolog, but then how does everything fit together for that to actually work?

If this is a big no-no in Magento 2, then what is the alternative? I want something to separate the logs for this extension for the purpose of debugging it when necessary on client sites. Having that info written to system.log, exception.log, etc. and jumbled with the logs of every other module is not practical.

In Magento 1, it was common to segment logs into different files (to separate logs for payment methods, etc.). That's as easy as changing the $file parameter of Mage::log.

Magento 2 has changed to use Monolog.

It appears that Monolog (or Magento2's implementation of it) segments all logs for the entire framework to handlers by severity. There are a few handlers that write to file:  \Magento\Framework\Logger\Handler\Debug, \Magento\Framework\Logger\Handler\Exception, \Magento\Framework\Logger\Handler\System, logging to respective files in var/log as in Magento 1.

I could add a handler for a particular severity (IE, write notices to var/log/notice.log). Extend \Magento\Framework\Logger\Handler\Base, and register the handler in di.xml.

This article roughly describes that process: http://semaphoresoftware.kinja.com/how-to-create-a-custom-log-in-magento-2-1704130912

But how do I go about writing all logs (not just one severity) for one class (not all of Magento) to my file of choice?

It looks like I'll have to create my own version of Magento\Framework\Logger\Monolog, but then how does everything fit together for that to actually work?

If this is a big no-no in Magento 2, then what is the alternative? I want something to separate the logs for this extension for the purpose of debugging it when necessary on client sites. Having that info written to system.log, exception.log, etc. and jumbled with the logs of every other module is not practical.

In Magento 1, it was common to segment logs into different files (to separate logs for payment methods, etc.). That's as easy as changing the $file parameter of Mage::log.

Magento 2 has changed to use Monolog.

It appears that Monolog (or Magento2's implementation of it) segments all logs for the entire framework to handlers by severity. There are a few handlers that write to file: 

\Magento\Framework\Logger\Handler\Debug, \Magento\Framework\Logger\Handler\Exception, \Magento\Framework\Logger\Handler\System

Logging to respective files in var/log as in Magento 1.

I could add a handler for a particular severity (IE, write notices to var/log/notice.log). Extend \Magento\Framework\Logger\Handler\Base, and register the handler in di.xml.

This article roughly describes that process: http://semaphoresoftware.kinja.com/how-to-create-a-custom-log-in-magento-2-1704130912

But how do I go about writing all logs (not just one severity) for one class (not all of Magento) to my file of choice?

It looks like I'll have to create my own version of Magento\Framework\Logger\Monolog, but then how does everything fit together for that to actually work?

If this is a big no-no in Magento 2, then what is the alternative? I want something to separate the logs for this extension for the purpose of debugging it when necessary on client sites. Having that info written to system.log, exception.log, etc. and jumbled with the logs of every other module is not practical.

3 edited title
| link

Logging How to acreate custom Log file in Magento 2?

2 deleted 11 characters in body
source | link

In Magento 1, it was common to segment logs into different files (to separate logs for payment methods, etc.). That's as easy as changing the $file parameter of Mage::log.

Magento 2 has changed to use Monolog.

It appears that Monolog (or Magento2's implementation of it) segments all logs for the entire framework to handlers by severity. There are a few handlers that write to file: \Magento\Framework\Logger\Handler\Debug, \Magento\Framework\Logger\Handler\Exception, \Magento\Framework\Logger\Handler\System, logging to respective files in var/log as in Magento 1.

I could add a handler for a particular severity (IE, write notices to var/log/notice.log). Extend \Magento\Framework\Logger\Handler\Base, and register the handler in di.xml.

This article roughly describes that process: http://semaphoresoftware.kinja.com/how-to-create-a-custom-log-in-magento-2-1704130912

But how do I go about writing all logs (not just one severity) for one class (not all of Magento) to my file of choice?

It looks like I'll have to create my own version of Magento\Framework\Logger\Monolog, but then how does everything fit together for that to actually work?

If this is a big no-no in Magento 2, then what is the alternative? I want something to separate the logs for this extension for the purpose of debugging it when necessary on client sites. Having that info written to system.log, exception.log, etc. and jumbled with the logs of every other module is not practical.

Thanks.

In Magento 1, it was common to segment logs into different files (to separate logs for payment methods, etc.). That's as easy as changing the $file parameter of Mage::log.

Magento 2 has changed to use Monolog.

It appears that Monolog (or Magento2's implementation of it) segments all logs for the entire framework to handlers by severity. There are a few handlers that write to file: \Magento\Framework\Logger\Handler\Debug, \Magento\Framework\Logger\Handler\Exception, \Magento\Framework\Logger\Handler\System, logging to respective files in var/log as in Magento 1.

I could add a handler for a particular severity (IE, write notices to var/log/notice.log). Extend \Magento\Framework\Logger\Handler\Base, and register the handler in di.xml.

This article roughly describes that process: http://semaphoresoftware.kinja.com/how-to-create-a-custom-log-in-magento-2-1704130912

But how do I go about writing all logs (not just one severity) for one class (not all of Magento) to my file of choice?

It looks like I'll have to create my own version of Magento\Framework\Logger\Monolog, but then how does everything fit together for that to actually work?

If this is a big no-no in Magento 2, then what is the alternative? I want something to separate the logs for this extension for the purpose of debugging it when necessary on client sites. Having that info written to system.log, exception.log, etc. and jumbled with the logs of every other module is not practical.

Thanks.

In Magento 1, it was common to segment logs into different files (to separate logs for payment methods, etc.). That's as easy as changing the $file parameter of Mage::log.

Magento 2 has changed to use Monolog.

It appears that Monolog (or Magento2's implementation of it) segments all logs for the entire framework to handlers by severity. There are a few handlers that write to file: \Magento\Framework\Logger\Handler\Debug, \Magento\Framework\Logger\Handler\Exception, \Magento\Framework\Logger\Handler\System, logging to respective files in var/log as in Magento 1.

I could add a handler for a particular severity (IE, write notices to var/log/notice.log). Extend \Magento\Framework\Logger\Handler\Base, and register the handler in di.xml.

This article roughly describes that process: http://semaphoresoftware.kinja.com/how-to-create-a-custom-log-in-magento-2-1704130912

But how do I go about writing all logs (not just one severity) for one class (not all of Magento) to my file of choice?

It looks like I'll have to create my own version of Magento\Framework\Logger\Monolog, but then how does everything fit together for that to actually work?

If this is a big no-no in Magento 2, then what is the alternative? I want something to separate the logs for this extension for the purpose of debugging it when necessary on client sites. Having that info written to system.log, exception.log, etc. and jumbled with the logs of every other module is not practical.

    Tweeted twitter.com/#!/StackMagento/status/627990278624907264
1
source | link