How to implement the following event in Magento : As soon as the customer logs in the details are printed in the log file [duplicate]Magento 2: Get Customer data after login with observerMagento 2: Replacement for Mage::log method?Magento 2 is not generating the db_schema_whitelist.json file via CLImagento 2 how to print logMagento 2 : Create file type customer attributeUpdate custom data for customerHow to override the checkout_cart_configure.xml template file into custom module“PasswordHash” does not have accessor method “getPasswordHash” in class “MagentoCustomerApiDataCustomerInterface”How to debug checkout_cart_product_add_after event on exitMagento 2 Assign customer group name to externally calling JavaScript file variableMagento 2.3.1 : No such entity with customerId = Backend Login as Customer Logs pageMagento 2: Customer name not display in programmatically logged in user account

How to ask my manager for a part-time?

Idioms: Should it be " the internet is a seemingly infinite well of information" or "the internet is a seemingly infinite wealth of information"

Short story about a group of sci-fi writers sitting around discussing their profession

Why must API keys be kept private?

What is an Eternal Word™?

How may I shorten this shell script?

How could an engineer advance human civilization by time traveling to the past?

Why are there not any MRI machines available in Interstellar?

The seven story archetypes. Are they truly all of them?

Found more old paper shares from broken up companies

Can 々 stand for a duplicated kanji with a different reading?

Download file from URL to Safehouse

Why can't a country print its own money to spend it only abroad?

Travelling from Venice to Budapest, making a stop in Croatia

Using paddles to support a bug net

Sometimes you are this word with three vowels

Historicity doubted by Romans

Inverse Colombian Function

Is the Game Boy Sharp LR35902 object-compatible with the 8080/Z-80?

Why has DC been so Democratic compared to other states in the last presidential election?

Raw curve25519 public key points

Considerations when providing money to one child now, and the other later?

Where is this photo of a group of hikers taken? Is it really in the Ural?

Can I pay with HKD in Macau or Shenzhen?



How to implement the following event in Magento : As soon as the customer logs in the details are printed in the log file [duplicate]


Magento 2: Get Customer data after login with observerMagento 2: Replacement for Mage::log method?Magento 2 is not generating the db_schema_whitelist.json file via CLImagento 2 how to print logMagento 2 : Create file type customer attributeUpdate custom data for customerHow to override the checkout_cart_configure.xml template file into custom module“PasswordHash” does not have accessor method “getPasswordHash” in class “MagentoCustomerApiDataCustomerInterface”How to debug checkout_cart_product_add_after event on exitMagento 2 Assign customer group name to externally calling JavaScript file variableMagento 2.3.1 : No such entity with customerId = Backend Login as Customer Logs pageMagento 2: Customer name not display in programmatically logged in user account






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1
















This question already has an answer here:



  • Magento 2: Get Customer data after login with observer

    3 answers



I have to print the login details of the customer and when he logged in, into the log file. How to implement the following problem in Magento 2.










share|improve this question













marked as duplicate by Prince Patel, Piyush, Manashvi Birla, Amit Bera Jul 15 at 12:23


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • I need to print in customer log and not just fetch details

    – Naiwrita09
    Jul 15 at 5:48

















1
















This question already has an answer here:



  • Magento 2: Get Customer data after login with observer

    3 answers



I have to print the login details of the customer and when he logged in, into the log file. How to implement the following problem in Magento 2.










share|improve this question













marked as duplicate by Prince Patel, Piyush, Manashvi Birla, Amit Bera Jul 15 at 12:23


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















  • I need to print in customer log and not just fetch details

    – Naiwrita09
    Jul 15 at 5:48













1












1








1









This question already has an answer here:



  • Magento 2: Get Customer data after login with observer

    3 answers



I have to print the login details of the customer and when he logged in, into the log file. How to implement the following problem in Magento 2.










share|improve this question















This question already has an answer here:



  • Magento 2: Get Customer data after login with observer

    3 answers



I have to print the login details of the customer and when he logged in, into the log file. How to implement the following problem in Magento 2.





This question already has an answer here:



  • Magento 2: Get Customer data after login with observer

    3 answers







magento2.3






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jul 15 at 5:15









Naiwrita09Naiwrita09

268 bronze badges




268 bronze badges




marked as duplicate by Prince Patel, Piyush, Manashvi Birla, Amit Bera Jul 15 at 12:23


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by Prince Patel, Piyush, Manashvi Birla, Amit Bera Jul 15 at 12:23


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • I need to print in customer log and not just fetch details

    – Naiwrita09
    Jul 15 at 5:48

















  • I need to print in customer log and not just fetch details

    – Naiwrita09
    Jul 15 at 5:48
















I need to print in customer log and not just fetch details

– Naiwrita09
Jul 15 at 5:48





I need to print in customer log and not just fetch details

– Naiwrita09
Jul 15 at 5:48










1 Answer
1






active

oldest

votes


















1














You can use event customer_login which will give you all customer data. Check here.



https://magento.stackexchange.com/a/178884/49826



For print in logs do as below.




Vendor/Module/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 name="customer_login">
<observer name="customer_login_observer" instance="LazyCoderPaymentDeadlinesObserverCustomerLogin" />
</event>
</config>



Vendor/Module/Obsever/CustomerLogin.php




 <?php
namespace LazyCoderPaymentDeadlinesObserver;

use MagentoFrameworkEventObserverInterface;
use MagentoFrameworkEventObserver as EventObserver;

class CustomerLogin implements ObserverInterface

public function execute(EventObserver $observer)

$customer = $observer->getEvent()->getCustomer();
$name = $customer->getName(); //Get customer name


$writer = new ZendLogWriterStream(BP . '/var/log/logfile.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$logger->info($name); // Simple Text Log









share|improve this answer

























  • I have to use this within the execute function within the observer?

    – Naiwrita09
    Jul 15 at 5:21











  • can you provide me the controller file how to call this observer?

    – Naiwrita09
    Jul 15 at 5:33











  • No need for controller You only need to create observer and print data to log using above code.

    – Vivek
    Jul 15 at 5:48











  • My observer file:

    – Naiwrita09
    Jul 15 at 5:50






  • 1





    yes It worked thank you so much

    – Naiwrita09
    Jul 15 at 6:58



















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You can use event customer_login which will give you all customer data. Check here.



https://magento.stackexchange.com/a/178884/49826



For print in logs do as below.




Vendor/Module/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 name="customer_login">
<observer name="customer_login_observer" instance="LazyCoderPaymentDeadlinesObserverCustomerLogin" />
</event>
</config>



Vendor/Module/Obsever/CustomerLogin.php




 <?php
namespace LazyCoderPaymentDeadlinesObserver;

use MagentoFrameworkEventObserverInterface;
use MagentoFrameworkEventObserver as EventObserver;

class CustomerLogin implements ObserverInterface

public function execute(EventObserver $observer)

$customer = $observer->getEvent()->getCustomer();
$name = $customer->getName(); //Get customer name


$writer = new ZendLogWriterStream(BP . '/var/log/logfile.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$logger->info($name); // Simple Text Log









share|improve this answer

























  • I have to use this within the execute function within the observer?

    – Naiwrita09
    Jul 15 at 5:21











  • can you provide me the controller file how to call this observer?

    – Naiwrita09
    Jul 15 at 5:33











  • No need for controller You only need to create observer and print data to log using above code.

    – Vivek
    Jul 15 at 5:48











  • My observer file:

    – Naiwrita09
    Jul 15 at 5:50






  • 1





    yes It worked thank you so much

    – Naiwrita09
    Jul 15 at 6:58















1














You can use event customer_login which will give you all customer data. Check here.



https://magento.stackexchange.com/a/178884/49826



For print in logs do as below.




Vendor/Module/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 name="customer_login">
<observer name="customer_login_observer" instance="LazyCoderPaymentDeadlinesObserverCustomerLogin" />
</event>
</config>



Vendor/Module/Obsever/CustomerLogin.php




 <?php
namespace LazyCoderPaymentDeadlinesObserver;

use MagentoFrameworkEventObserverInterface;
use MagentoFrameworkEventObserver as EventObserver;

class CustomerLogin implements ObserverInterface

public function execute(EventObserver $observer)

$customer = $observer->getEvent()->getCustomer();
$name = $customer->getName(); //Get customer name


$writer = new ZendLogWriterStream(BP . '/var/log/logfile.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$logger->info($name); // Simple Text Log









share|improve this answer

























  • I have to use this within the execute function within the observer?

    – Naiwrita09
    Jul 15 at 5:21











  • can you provide me the controller file how to call this observer?

    – Naiwrita09
    Jul 15 at 5:33











  • No need for controller You only need to create observer and print data to log using above code.

    – Vivek
    Jul 15 at 5:48











  • My observer file:

    – Naiwrita09
    Jul 15 at 5:50






  • 1





    yes It worked thank you so much

    – Naiwrita09
    Jul 15 at 6:58













1












1








1







You can use event customer_login which will give you all customer data. Check here.



https://magento.stackexchange.com/a/178884/49826



For print in logs do as below.




Vendor/Module/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 name="customer_login">
<observer name="customer_login_observer" instance="LazyCoderPaymentDeadlinesObserverCustomerLogin" />
</event>
</config>



Vendor/Module/Obsever/CustomerLogin.php




 <?php
namespace LazyCoderPaymentDeadlinesObserver;

use MagentoFrameworkEventObserverInterface;
use MagentoFrameworkEventObserver as EventObserver;

class CustomerLogin implements ObserverInterface

public function execute(EventObserver $observer)

$customer = $observer->getEvent()->getCustomer();
$name = $customer->getName(); //Get customer name


$writer = new ZendLogWriterStream(BP . '/var/log/logfile.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$logger->info($name); // Simple Text Log









share|improve this answer















You can use event customer_login which will give you all customer data. Check here.



https://magento.stackexchange.com/a/178884/49826



For print in logs do as below.




Vendor/Module/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 name="customer_login">
<observer name="customer_login_observer" instance="LazyCoderPaymentDeadlinesObserverCustomerLogin" />
</event>
</config>



Vendor/Module/Obsever/CustomerLogin.php




 <?php
namespace LazyCoderPaymentDeadlinesObserver;

use MagentoFrameworkEventObserverInterface;
use MagentoFrameworkEventObserver as EventObserver;

class CustomerLogin implements ObserverInterface

public function execute(EventObserver $observer)

$customer = $observer->getEvent()->getCustomer();
$name = $customer->getName(); //Get customer name


$writer = new ZendLogWriterStream(BP . '/var/log/logfile.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$logger->info($name); // Simple Text Log










share|improve this answer














share|improve this answer



share|improve this answer








edited Jul 15 at 6:33

























answered Jul 15 at 5:17









VivekVivek

2,0281 gold badge9 silver badges38 bronze badges




2,0281 gold badge9 silver badges38 bronze badges












  • I have to use this within the execute function within the observer?

    – Naiwrita09
    Jul 15 at 5:21











  • can you provide me the controller file how to call this observer?

    – Naiwrita09
    Jul 15 at 5:33











  • No need for controller You only need to create observer and print data to log using above code.

    – Vivek
    Jul 15 at 5:48











  • My observer file:

    – Naiwrita09
    Jul 15 at 5:50






  • 1





    yes It worked thank you so much

    – Naiwrita09
    Jul 15 at 6:58

















  • I have to use this within the execute function within the observer?

    – Naiwrita09
    Jul 15 at 5:21











  • can you provide me the controller file how to call this observer?

    – Naiwrita09
    Jul 15 at 5:33











  • No need for controller You only need to create observer and print data to log using above code.

    – Vivek
    Jul 15 at 5:48











  • My observer file:

    – Naiwrita09
    Jul 15 at 5:50






  • 1





    yes It worked thank you so much

    – Naiwrita09
    Jul 15 at 6:58
















I have to use this within the execute function within the observer?

– Naiwrita09
Jul 15 at 5:21





I have to use this within the execute function within the observer?

– Naiwrita09
Jul 15 at 5:21













can you provide me the controller file how to call this observer?

– Naiwrita09
Jul 15 at 5:33





can you provide me the controller file how to call this observer?

– Naiwrita09
Jul 15 at 5:33













No need for controller You only need to create observer and print data to log using above code.

– Vivek
Jul 15 at 5:48





No need for controller You only need to create observer and print data to log using above code.

– Vivek
Jul 15 at 5:48













My observer file:

– Naiwrita09
Jul 15 at 5:50





My observer file:

– Naiwrita09
Jul 15 at 5:50




1




1





yes It worked thank you so much

– Naiwrita09
Jul 15 at 6:58





yes It worked thank you so much

– Naiwrita09
Jul 15 at 6:58