Лучший вопрос - не как, а почему вы хотите это сделать?Почему бы не определить две LogError
перегрузки, одна из которых принимает Exception
, а другая - string
.
private static void LogError(Exception ex)
{
// write ex to one log file
// write ex.message to another log file
}
private static void LogError(string error)
{
//nothing to write to exception-specific log file
// write error info to another log file
}
На самом деле не рекомендуется создавать собственный экземпляр Exception
только для такой регистрации.