You see, to log is mandatory if your software does more than a hello world. But the thing is, I've always thought it wasn't cool to stuff chunks of code all over the code, it makes the code ugly, and less readable.
I was using Log4Net, and it is not all bad, but as I said before, I don't like my code "dirty".
So today a friend of mine told me about the ELMAH, and I thought it is amazing. You might say it isn't that clean, if you want to log something you have to write code to log.
Of course you have, how else it is supposed to guess what you want to log???
But that's not even the most important part, the log caught errors and log them in a very nice way.
As I was trying to set aside a few hours to install and configure it, I've remembered one old Scott Hanselman's video about the
This works like a charm, you can have it all in 3 simple steps:
- Install the ELMAH nuget.
- Create a database for it and run the sql file App_Readme/Elmah.SqlServer.sql
- Update the ELMAH connection string in your web.config, just look for the already created key: <add name="elmah-sqlserver" connectionString="Data Source=****;User ID=****;Password=****;Initial Catalog=****;" providerName="System.Data.SqlClient" /> and then insert values about the database you just created.
Ah, and No, you don't have to look database records, or a shitty unformated text file...
Just access yourapp/elmah.axd and you will see something like this:
And clicking details, will be something like this:
Go ahead and start