-
-
Save damianh/4214487 to your computer and use it in GitHub Desktop.
LogParamsOnException
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Before | |
public class SimpleClass | |
{ | |
[LogParamsOnException(LogLevel.Info)] | |
void Method(string param1, int param2) | |
{ | |
//Do Stuff | |
} | |
} | |
After | |
public class SimpleClass | |
{ | |
static Logger logger; | |
static SimpleClass() | |
{ | |
logger = LogManager.GetCurrentClassLogger(); | |
} | |
void Method(string param1, int param2) | |
{ | |
try | |
{ | |
//Do Stuff | |
} | |
catch (Exception exception) | |
{ | |
logger.InfoException(() => string.Format("Exception occurred in SimpleClass.Method. param1 '{0}', param2 '{1}'", param1, param2), exception); | |
throw; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment