This library will report all exceptions that you log using log4net.
try
{
SomeBusinessCode();
}
catch (Exception ex)
{
_logger.Debug("Failed to do business", ex);
}
Will result in an exception in codeRR with the following (extra) context information:
- Download and install the codeRR Community Server or create an account at coderrapp.com
- Install this client library (using nuget
coderr.client.log4net
) - Configure the credentials from your codeRR account in your
Program.cs
. - Add the following line to activate this library:
Err.Configuration.CatchLog4NetExceptions();
Full example:
namespace Coderr.Client.Log4net.Demo
{
internal class Program
{
private static void Main(string[] args)
{
XmlConfigurator.Configure(new FileInfo("log4net.config"));
//when using our live service.
var url = new Uri("https://report.coderr.io/");
Err.Configuration.Credentials(url,
"yourAppKey",
"yourSharedSecret");
// injects into the log4net pipeline
Err.Configuration.CatchLog4NetExceptions();
//try the config
var log = LogManager.GetLogger(typeof(Program));
log.Info("Hello word");
var service = new SomeService();
service.DoSomeStuff();
Console.WriteLine("Exception have been logged.");
Console.ReadLine();
}
}
}
You need to either install Coderr Community Server or use Coderr Live.
- Questions? http://discuss.coderr.io
- Documentation: https://coderr.io/documentation/client/libraries/log4net/