You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you may know, the exception filter stuff doesn't work the same in ASP.NET vNext as far as I can tell. The following steps work there instead. Consider updating the docs or adding a separate readme?
Create an ILogger:
public class RollbarExceptionLogger : ILogger
{
public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func<object, Exception, string> formatter)
{
if (exception == null)
return;
const string accessToken = "YOUR_SERVER_ACCESS_TOKEN";
RollbarClient rollbar = new RollbarClient(accessToken);
rollbar.SendException(exception);
}
public bool IsEnabled(LogLevel logLevel)
{
#if DEBUG
return false;
#else
return true;
#endif
}
public IDisposable BeginScopeImpl(object state)
{
return null;
}
}
Next create a ILoggerProvider to generate them upon request.
public class RollbarExceptionLoggerProvider : ILoggerProvider
{
public void Dispose()
{
}
public ILogger CreateLogger(string categoryName)
{
return new RollbarExceptionLogger();
}
}
Finally, install it in your Startup.cs's configure method call:
public class Startup
{
public void Configure(IApplicationBuilder app, IHostingEnvironment env,
ILoggerFactory loggerFactory, IOptions<MvcJsonOptions> mvcOptions )
{
Environment = env;
mvcOptions.Value.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddProvider(new RollbarExceptionLoggerProvider());
loggerFactory.AddDebug();
// ...
}
}
The text was updated successfully, but these errors were encountered:
As you may know, the exception filter stuff doesn't work the same in ASP.NET vNext as far as I can tell. The following steps work there instead. Consider updating the docs or adding a separate readme?
Create an ILogger:
Next create a ILoggerProvider to generate them upon request.
Finally, install it in your Startup.cs's configure method call:
The text was updated successfully, but these errors were encountered: