Created
January 27, 2015 21:16
-
-
Save jptoto/9be57ce2fe253eb96739 to your computer and use it in GitHub Desktop.
Custom Exception w/ Log4net
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Runtime.Serialization; | |
using System.Text; | |
using System.Threading.Tasks; | |
using log4net; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
private static readonly ILog _log = LogManager.GetLogger(typeof(Program)); | |
static void Main(string[] args) | |
{ | |
_log.Error("kaboom!", new CustomException { SomeValue1 = "some value 1", SomeValue2 = "some value 2"}); | |
} | |
} | |
public class CustomException : Exception | |
{ | |
public CustomException() | |
: base() { } | |
public CustomException(string message) | |
: base(message) { } | |
public CustomException(string format, params object[] args) | |
: base(string.Format(format, args)) { } | |
public CustomException(string message, Exception innerException) | |
: base(message, innerException) { } | |
public CustomException(string format, Exception innerException, params object[] args) | |
: base(string.Format(format, args), innerException) { } | |
protected CustomException(SerializationInfo info, StreamingContext context) | |
: base(info, context) { } | |
public string SomeValue1 { get; set; } | |
public string SomeValue2 { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment