Skip to content

Try Catch does not log #51

@ShaunStanley

Description

@ShaunStanley

Hi,

I am new to logging and currently exploring logging frameworks, while testing out this framework, when I have a try catch condition, it seems like the Exception log is not logged. Perhaps anyone could advise regarding this matter?

Here is my test code (using MVC architecture and this section of code is in the controller):
public async Task TestError()
{
int statCode = 0;
string msg = "";
try
{
Guid g = new Guid("ABC"); //Here it will definitely create an error since "ABC" is not a proper Guid format
statCode = 200;
msg = g.ToString();
}
catch (Exception ex)
{
statCode = 500;
msg = ex.ToString();
}
return StatusCode(statCode, msg);
}

Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions