I am using 3 tier architecture in asp.net, I want to put function "ErrorLog()" to log errors, where should I put in my structure?
3 Answers
I suggest you to write your Error log code in your Global.asax
file.
It has function called Application_Error
. This function is called automatically if an
unhandled exception is raised.
You can create your log file there. It has Server.GetLastError()
function that keeps the track of your last error in your project.
For more details check this link this will help you.

- 1
- 1
You can create a Uility folder under BLL which holds common functions like CommonFunction.cs class. In that class you can put ErrorLog , AlertMessage,Encrypt , Decrypt ... functions

- 2,031
- 8
- 33
- 53
I would suggest not to put ErrorLog() in any layer (depending on your structure, layer can be a namespace OR a project).
It should be in a Error Utility class and not in any layer, as you might want to use this to log errors from either data layer or business layer.

- 282
- 1
- 14