Skip to content

Instantly share code, notes, and snippets.

@damianh
Forked from SimonCropp/gist:4214439
Created December 5, 2012 10:14
Show Gist options
  • Save damianh/4214487 to your computer and use it in GitHub Desktop.
Save damianh/4214487 to your computer and use it in GitHub Desktop.
LogParamsOnException
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