aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Web/TangoWebApplication.cs
blob: 137942071ea2f95d99447b5d2f312f69b2991d19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
using System.Web.Http.Filters;
using System.Web.Mvc;
using Tango.Core;
using Tango.Logging;
using Tango.Web.Logging;

namespace Tango.Web
{
    public class TangoWebApplication : HttpApplication
    {
        //Create filter
        public class LogExceptionFilterAttribute : ExceptionFilterAttribute
        {
            public override void OnException(HttpActionExecutedContext context)
            {
                LogManager.Default.Log(context.Exception);
            }
        }

        protected virtual void Application_Start()
        {
            LogManager.Default.Categories.Add(LogCategory.Debug);
            LogManager.Default.RegisterLogger(new AzureCloudLogger());
            GlobalConfiguration.Configuration.Filters.Add(new LogExceptionFilterAttribute());

            SynchronizedObservableCollectionConfig.DisableSynchronization = true;

            LogManager.Default.Log("Application Started!");
        }

        protected void Application_Error(object sender, EventArgs e)
        {
            Exception exception = Server.GetLastError();
            if (exception != null)
            {
                LogManager.Default.Log(exception, "Global Exception!");
            }
        }
    }
}