Comments (7)
Just install the nuget package and use the target Elmah
I will write a better how to soon :)
from nlog.elmah.
You need to create an NLog config. That could by a XML (nlog.config) file or C#, please read
https://github.com/NLog/NLog/wiki/Tutorial
the target in this case is Elmah, so somthing like this
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="target1" xsi:type="Elmah" />
</targets>
<rules>
<logger name="*" minlevel="Info" writeTo="target1" />
</rules>
</nlog>
from nlog.elmah.
updated: https://github.com/NLog/NLog.Elmah#usage
from nlog.elmah.
good point, thanks!
from nlog.elmah.
Thanks, @304NotModified. A follow-up: I've installed the package and added the attribute,
[Target("Elmah")]
public class HomeController : Controller
{
private static Logger _logger = LogManager.GetCurrentClassLogger();
public ActionResult Index()
{
LogEventInfo logEvent = new LogEventInfo(LogLevel.Info, _logger.Name, "Some error by alex");
_logger.Log(logEvent);
return View();
}
public ActionResult About()
{
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
But it's not writing to Elmah, though it is writing to NLog when I go to Index
. I have the Elmah.MVC package installed, so I can go to /Elmah
and see the errors.
from nlog.elmah.
Thanks, @304NotModified! Very nice instructions!
That fixed it. Also, users can safely ignore the warning it throws for that custom target:
This is an invalid xsi:type 'http://www.nlog-project.org/schemas/NLog.xsd:Elmah'
from nlog.elmah.
Answered my question on this using your library: https://stackoverflow.com/a/44974578/177416
Update: Fixed the xml not showing up in SO answer.
from nlog.elmah.
Related Issues (11)
- Need docs HOT 1
- .NET Core support? HOT 4
- Apply Elmah target to all controllers HOT 2
- Only log to ELMAH if there's an exception HOT 1
- Add license file + license to nupkg
- Build fails due to licenseUrl and PackageIcon HOT 2
- migrate to xUnit HOT 1
- add CodeCov HOT 1
- Can't set Elmah Source. HOT 8
- Release nlog 4 compatible version HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nlog.elmah.