using System;
using System.Web.Routing;
using System.Web.Mvc;
[assembly: WebActivatorEx.PostApplicationStartMethod(
typeof(KREATE_MVC.App_Start.JSNLogConfig), "PostStart")]
namespace Example.App_Start {
public static class JSNLogConfig {
public static void PostStart() {
var jsnlogRoute = new Route("{*jsnloglogger}", new StopRoutingHandler());
jsnlogRoute.Constraints = new RouteValueDictionary {{ "jsnloglogger", @"jsnlog\.logger(/.*)?" }};
RouteTable.Routes.Insert(0, jsnlogRoute);
}
}
<a href="~/Scripts/jsnlog.js.map"></a>
<script src="~/Scripts/jsnlog.min.js"></script>
<script src="~/Scripts/jsnlog.js"></script>
<script>
$(document).ready(function () {
debugger
try{
throw 500;
}
catch(msg)
{
alert(JL("jslogger").error("This is an error!"))
}
})
</script>
@using Microsoft.AspNet.Identity
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - KREATE OM</title>
@Html.Raw(JSNLog.JavascriptLogging.Configure())
//This is my Nlog config
<?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"
internalLogFile="D:\logtest\myapplication.log">
<targets async="true">
<!--<target name="file" xsi:type="File"
layout="${longdate}|${level}|
${processtime}|${processname}|${message}|
${threadid}|${exception}|${stacktrace}"
fileName="D:\KreateLog_Web.txt" />-->
<target xsi:type="file"
name="jslogger"
fileName="D:\KreateLog_Web.txt"
createDirs="true"
layout="${longdate}|${level:uppercase=true}|${logger}|${aspnet-user-identity}|${message}"
/>
<!--<target name="database" type="Database">
<connectionString>
</connectionString>
<commandText>
"insert into [KREATE_OM].[COMMON].[ErrorLog](SourceApp,LogDate,Level,ContextData,ProcessTime,ProcessName,MachineName,UserName,
Thread, ErrorMessageAndStackTrace, Nlog_Stacktrace)
values(@SourceApp, @LogDate, @Level, @ContextData,@ProcessTime, @ProcessName, @MachineName, @UserName,
@Thread,@ErrorMessageAndStackTrace, @Nlog_Stacktrace);"
</commandText>
<parameter name="@SourceApp" layout="${logger}"/>
<parameter name="@LogDate" layout="${longdate}"/>
<parameter name="@Level" layout="${level}"/>
<parameter name="@ContextData" layout="${event-properties:item=AppData}"/>
<parameter name="@logger" layout="${appdomain}"/>
<parameter name="@ProcessTime" layout="${processtime}"/>
<parameter name="@ProcessName" layout="${processname}"/>
<parameter name="@MachineName" layout="${machinename}"/>
<parameter name="@UserName" layout="${windows-identity:domain=true}"/>
<parameter name="@Thread" layout="${threadid}"/>
<parameter name="@ErrorMessageAndStackTrace" layout="${message}"/>
<parameter name="@Nlog_Stacktrace" layout="${stacktrace}"/>
</target>-->
</targets>
<rules>
<!-- Development Environment -->
<!--<logger name="*" levels="Debug,Error,Info,Trace,Warn,Fatal" writeTo="file"/>-->
<!--<logger name="*" levels="Debug,Error,Info,Trace,Warn,Fatal" writeTo="file"/>
--><!-- Production Environment --><!--
<logger name="*" levels="Error,Fatal" appendTo="database"/>-->
<logger levels="Error,Warn,Fatal" name="jslogger" writeTo="file"/>
<!--<logger name="*" writeTo="logger" />-->
</rules>
</nlog>
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http:
-->
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http:
<section name="jsnlog" type="JSNLog.ConfigurationSectionHandler, JSNLog" requirePermission="false" />
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup><sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup></configSections>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="DefaultConnection" value="DefaultConnection" />
<add key="enableSimpleMembership" value="false" />
</appSettings>
<!--
For a description of web.config changes see http:
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5" />
</system.Web>
-->
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<roleManager enabled="true" />
<httpHandlers>
<add verb="*" path="*.logger" type="JSNLog.LoggerHandler, JSNLog" />
</httpHandlers><httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules></system.web>
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
<remove name="RoleManager" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" /><add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" /><add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" /></modules>
<validation validateIntegratedModeConfiguration="false" /><handlers>
<add name="LoggerHandler" verb="*" path="*.logger" type="JSNLog.LoggerHandler, JSNLog" resourceType="Unspecified" preCondition="integratedMode" />
<add name="LoggerHandler-Classic" path="*.logger" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode" />
</handlers></system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.AspNet.Identity.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.1.0" newVersion="3.3.1.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Common.Logging.Core" publicKeyToken="af08829b84f0328e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.1.0" newVersion="3.3.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
</compilers>
</system.codedom>
<jsnlog
enabled="true|false"
maxMessages="number"
defaultAjaxUrl="string"
corsAllowedOriginsRegex="string"
serverSideLogger="string"
serverSideLevel="number|TRACE|DEBUG|INFO|WARN|ERROR|FATAL"
serverSideMessageFormat="%logger|%url|%utcDate|%message"
dateFormat="string"
productionLibraryPath="string">
</jsnlog>
<common>
<logging>
<factoryAdapter type="Common.Logging.NLog.NLogLoggerFactoryAdapter, Common.Logging.NLog20">
<arg key="configType" value="INLINE" />
</factoryAdapter>
<factoryAdapter type="Common.Logging.Elmah.v2.ElmahLoggerFactoryAdapter, Common.Logging.Elmah.v2">
<arg key="MinLevel" value="all" />
</factoryAdapter></logging>
</common>
<elmah>
<security allowRemoteAccess="false" />
<errorLog type="Elmah.Io.ErrorLog, Elmah.Io" apiKey="chaitra" logId="chaitra" />
</elmah><location path="elmah.axd" inheritInChildApplications="false">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<!--
See http:
more information on using ASP.NET authorization securing ELMAH.
<authorization>
<allow roles="admin" />
<deny users="*" />
</authorization>
-->
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
</handlers>
</system.webServer>
</location></configuration>
|