Writing information and exceptions from razor view to logs
Hello Team,
I am very new to umbraco i have installed Umbraco 12 version all iam going good but now i got stucked with logs
I have a razor view which is serving with content publish model and i don't have any controllers in my solution so now i need to log some information and which i can see in umbraco backoffice i used below syntax to write information log
@using Microsoft.Extensions.Logging
@inject ILogger logger
@{
logger.LogInformation("Hello, this is a test.");
try
{
logger.LogInformation("Hello, this is a test. Log is working");
}
catch (Exception ex)
{
logger.LogError(ex, "An error occurred.");
}
}
I have tried by registering service in start.cs and it looks like below
I wanted to express my sincere gratitude for your prompt and helpful response to my question. Your solution worked perfectly for me, and I truly appreciate the time and effort you put into assisting me.
Writing information and exceptions from razor view to logs
Hello Team,
I am very new to umbraco i have installed Umbraco 12 version all iam going good but now i got stucked with logs
I have a razor view which is serving with content publish model and i don't have any controllers in my solution so now i need to log some information and which i can see in umbraco backoffice i used below syntax to write information log
I have tried by registering service in start.cs and it looks like below
Can anyone please help me on this i stuck with since 8 hrs
Hi Venkat
I think you just need a c# class when you inject the logger into the razor view
Eg
@inject ILogger<UmbracoViewPage> _logger
I don't think you need to do anything in configure services...
Regards
Marc
Hi Marc Goodson,
I wanted to express my sincere gratitude for your prompt and helpful response to my question. Your solution worked perfectly for me, and I truly appreciate the time and effort you put into assisting me.
Thank you once again for your invaluable support!
is working on a reply...