Writing from code to Log

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 年 前
If I want to write a simple message to the Log regarding a user action, what is the (best) way to do so?
Should I use the 'DefaultLogger' or the 'CustomerActivityService'? And, more important, how? :)

Thanks in advance!
11 年 前
If you want to write to log (usually exceptions and errors), use 'ILogger/DefaultLogger'. If you want to write to an user activity (usually information such as "viewing a category", etc), use 'ICustomerActivityService'.
11 年 前
Hi Andrei,

Thanks for the quick reply. Could you please provide me with an example of the DefaultLogger service?

Thx!
11 年 前
Have a look at \src\Libraries\Nop.Services\Orders\OrderProcessingService.cs. ILogger is injected via contructor and used when required
11 年 前
Something like this?


Nop.Services.Logging.DefaultLogger logger = (Nop.Services.Logging.DefaultLogger)Nop.Core.Infrastructure.EngineContext.Current.Resolve<Nop.Services.Logging.ILogger>();
logger.InsertLog(Nop.Core.Domain.Logging.LogLevel.Information, "Customer doing something!", "Customer ......", null);
11 年 前
Yes. You can do it this way. But it's not very elegant. See my best above for more proper way of getting ILogger instance
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.