After a few emails back and forth between myself and Rajiv, (as well as Rajiv’s requests over at the ELMAH support group), the advice was to simpily develop some code that implemented the
ErrorLog class, (making use of the 3 core methods:
GetErrors). Rajiv make a start with this code, but ran into a few problems, (mostly because he was trying to reference methods/properties that were internal to the core
Given that I’d said it was quick and easy to develop this code, I best put my money (or time in this case) where my mouth was. Fifteen minutes later the code was written… and then another hour later, the code was tested and bugs fixed.
For the MySQL connectivity, I used the
MySql.Data.MySqlClient connector. For the
MySqlErrorLog, I followed the code/design patterns that Atif had used in both the core
I have uploaded the Visual Studio (2008) solution to the ELMAH support group file repo (here is a direct link to the ZIP) – you will need to compile the DLL from the solution. If you need a pre-compiled DLL, then give me a shout, I’ll sort something out.
Once you have the compiled Elmah.MySql.dll, you will need to add following to your Web.config file:
<elmah> section, change the
<errorLog> to: (if you haven’t installed ELMAH before, please see the WebBase)
<errorLog type="Elmah.MySqlErrorLog, Elmah.MySql" />
In the VS2008 solution, there is a script called MySql.sql – run this against your database to create the new table (called “elmah”) needed to log the errors/exceptions.
Then add your MySql connection string in the
<add name="ELMAH_MySql" connectionString="SERVER=localhost;DATABASE=elmah;USER=XXXX;PASSWORD=XXXX;" />
It is very important that you call the connection string “
ELMAH_MySql” – as this is hard-coded in the backend. (Let me know if this is a problem, I think it could be moved to the
Once you have saved the changes to your Web.config, you are all set to use MySql as your ELMAH back-end data-source!
- The “Sequence” column in the “elmah” table should be auto-incremental, but it isn’t! (I don’t claim to know enough about MySql to have multiple auto-incremental columns) – any suggestions?
- The MySql connection string is hard-coded as “
- The code will only compile with .NET 2.0 and above (no support for .NET 1.0 or 1.1 – sorry)
I have mentioned to Atif about the possibility of including MySql support to the ELMAH core – to which he is willing to do, only if I support it. Which I will be happy to do – but only if there is a need for it. So my suggestion would be, if you would like to see MySql support in the ELMAH core – then raise a feature request on the ELMAH Google Code site. Once it gains momentum, we’ll take it from there.