Giter Site home page Giter Site logo

How do you use this library? about nlog.elmah HOT 7 CLOSED

nlog avatar nlog commented on June 16, 2024
How do you use this library?

from nlog.elmah.

Comments (7)

304NotModified avatar 304NotModified commented on June 16, 2024 1

Just install the nuget package and use the target Elmah

I will write a better how to soon :)

from nlog.elmah.

304NotModified avatar 304NotModified commented on June 16, 2024 1

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.

304NotModified avatar 304NotModified commented on June 16, 2024 1

updated: https://github.com/NLog/NLog.Elmah#usage

from nlog.elmah.

304NotModified avatar 304NotModified commented on June 16, 2024 1

good point, thanks!

from nlog.elmah.

arc95 avatar arc95 commented on June 16, 2024

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.

arc95 avatar arc95 commented on June 16, 2024

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.

arc95 avatar arc95 commented on June 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.