Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Daniel Pazos 12 posts 123 karma points
    Feb 09, 2021 @ 19:49
    Daniel Pazos
    0

    Logger works in localhost but not deployed on Azure

    Hi,

    I've created a SurfaceController who uses a custom Service where I log some events.

    When I try my code in my machine I can see the logs in the Umbarco backoffice log viewer. But if I deploy my website to Azure, logs stops working.

    This is my code:

     public class ContactController : SurfaceController
    {
        private ISmtpClientService _service;
    
        public ContactController(ISmtpClientService service)
        {
            _service = service;
        }
    
    
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Submit(ContactFormModel model)
        {
            if (ModelState.IsValid)
            {
                model.Subject = $"Contact form - {model.Name}";
                bool success = _service.SendMessage(model);
            }
    
            return RedirectToCurrentUmbracoPage();
        }
    }
    

    And this is the Service I've created:

    public class SmtpClientService : ISmtpClientService
    {
        private readonly ILogger _logger;
    
        public SmtpClientService(ILogger logger)
        {
            _logger = logger;
        }
    
        public bool SendMessage(ContactFormModel model)
        {
            using (var client = new MailKit.Net.Smtp.SmtpClient())
            {
                try
                {
                    _logger.Info<SmtpClientService>("Start method.");
    

    Any idea why it is working in my machine but not once I deployed it?

    I'm using Umbraco v8.11.1

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft