How to configure Quartz.Net version 2.1.2.0 integrated with Log4Net - web-config

I have downloaded the newest version of Quartz.Net and try to configure it with common.logging and log4net dlls by using below configuration (based on this example)
<configSections>
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=2.1.2.400,Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4" />
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging, Version=2.1.2.0, Culture=neutral, PublicKeyToken=af08829b84f0328e" />
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<logging>
<factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
<arg key="configType" value="INLINE" />
</factoryAdapter>
</logging>
<log4net>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="MyQuartzLog.txt" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%-5p%d{yyyy-MM-dd hh:mm:ss} – %m%n" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
</root>
</log4net>
<quartz>
<add key="quartz.scheduler.instanceName" value="QuartzTestLog4Net" />
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.threadCount" value="10" />
<add key="quartz.threadPool.threadPriority" value="2" />
<add key="quartz.jobStore.misfireThreshold" value="60000" />
<add key="quartz.jobStore.type" value="Quartz.Simpl.RAMJobStore, Quartz" />
</quartz>
It does not work.
<section name="quartz" type="System.Configuration.NameValueSectionHandler, System, Version=2.1.2.400,Culture=neutral, PublicKeyToken=f6b8c98a402cc8a4" />
results in component loading error. I used sn.exe to check the publickeytoken. The keytoken is correct.
Removing the quartz sction can make the application run. But the log object has NoOpLogger information - {Common.Logging.Simple.NoOpLogger}.
My project refers to Common.Logging version 2.1.2.0; Common.Logging.Log4Net version 2.0.0.0; and log4net version 1.2.10.0. Are they right versions? If not, what are the right ones.
Thanks,

You should check the sample server that comes with Quartz.NET distribution.
https://github.com/quartznet/quartznet/tree/master/server/Quartz.Server
App.config:
It's type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"
NameValueSectionHandler is BCL type, not Quartz.NET's
You can probably leave out the version and public key
Package.config
You might have wrong packages. packages.config in sample contains working combination when using Log4Net 1.2.11

Related

Log4Net in Resharper Unit Test Runner but not in NUnit Unit Runner

I'm using the latest 5.x ReSharper plugin with NUnit 2.5.10. When using Log4Net to log some events for testing purposes the results show up in the ReSharper test window, but do not show up when using NUnit's console unit runner (run as part of our build processes). I've tried giving NUnit a .config file in the same location as the .nunit configuration file with the LogLevelThreshold set to DEBUG, but it still won't log the actual test information to either the output file or the text window in NUnit's GUI. I'm a bit stumped at this point, is there a way to get the two in sync in what's being displayed by test output? Thanks!
Configs in question:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="NUnit">
<section name="TestCaseBuilder" type="System.Configuration.NameValueSectionHandler"/>
<section name="TestRunner" type="System.Configuration.NameValueSectionHandler"/>
</sectionGroup>
</configSections>
<NUnit>
<TestRunner>
<add key="DefaultLogThreshold" value="DEBUG" />
</TestRunner>
</NUnit>
</configuration>
And other config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<log4net debug="false">
<appender name="console" type="log4net.Appender.ConsoleAppender, log4net">
<layout type="log4net.Layout.PatternLayout, log4net">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<appender name="DebugAppender" type="log4net.Appender.DebugAppender, log4net">
<layout type="log4net.Layout.PatternLayout, log4net">
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="console" />
<!--<appender-ref ref="DebugAppender" />-->
</root>
<logger name="NHibernate">
<level value="INFO" />
</logger>
<logger name="NHibernate.SQL">
<level value="DEBUG" />
</logger>
</log4net>
</configuration>
Thanks in advance for any help.

Elmah ignoring ErrorFilter

I am trying to have elmah ignore 404 errors but they keep showing up. I am using asp.net mvc 3.
I have
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah" logPath="~/App_Data" connectionStringName="ConnectionString" applicationName="/" />
<errorFilter>
<test>
<equal binding="HttpStatusCode" value="404" type="Int32" />
</test>
</errorFilter>
<security allowRemoteAccess="0" />
</elmah>
<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>
Am I missing something? I used nuget to generate the web.config so I would think everything is in the web.config.
Possibly an issue with module order like in this post?
ELMAH - Filtering 404 Errors

Elmah webconfig error 500 on Window2008r2 MVC2 Project

Just found out that i don't need httpHandler and the httpHandlers in the system.web and it still running
I have tried to integrate Elmah to my MVC2 Project and it works fine on my local, But when I upload it to the Web, which is window2008-r2. There i get "500 - Internal server error."
When i remove the httpHandler and the httpHandlers from the webconfig the the error is gone but elmah is not running.
Please help, how you I get it running on the 2008RC?
Here is what in my webconfig file:
<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"/>
<section name="errorTweet" requirePermission="false" type="Elmah.ErrorTweetSectionHandler, Elmah"/>
</sectionGroup>
...
...
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</httpModules>
<customErrors mode="RemoteOnly" defaultRedirect="/content/error.htm" />
...
...
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
</modules>
<handlers>
<add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
<remove name="UrlRoutingHandler"/>
</handlers>
...
<security allowRemoteAccess="0" />
<!--
quickest log method
-->
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/Content/ErrorLog" />
...
I am going to guess you are using .net 4.0 on your 2008 box and this module is not compatible with .net 4
What I did is download the source files and compiled it as .net 4 and had no issues. I am currently running Elmah on server 2008 using .net 4.0 and all is working just fine.
Just as a reference here is an excerpt from my web.config file
<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>
<elmah>
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="ConnectionString" />
<security allowRemoteAccess="0" />
</elmah>
<location path="elmah.axd">
<system.web>
<authorization>
<deny users="?" />
</authorization>
<httpRuntime requestLengthDiskThreshold="256" maxRequestLength="2097151" />
</system.web>
</location>
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
</httpModules>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah"/>
</modules>
<handlers>
<add name="Elmah" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</handlers>
</system.webServer>
whether or not httpHandlers is required in system.web is determined by whether you are on IIS6....It is better you keep both pieces as shown in the example by odyth so that it works fine for both IIS 6 and 7

Can't get ELMAH to works with ASP.NET MVC2 on IIS7.5

I try to use ELMAH on my ASP.NET MVC2 application, it works fine on the test server (Casini x86) while using the x86 version, but when I deploy it on the production server with the x86_64 version, I get a 404 error when I try to access "elmah.axd" and no errors are logged on IIS (but they are logged in Casini)
Here is my Web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<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>
<connectionStrings>
<add name="ApplicationServices" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=IronViper;Integrated Security=SSPI" providerName="System.Data.SqlClient" />
<add name="IronViperEntities" connectionString="metadata=res://*/Models.IronViper.csdl|res://*/Models.IronViper.ssdl|res://*/Models.IronViper.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;Initial Catalog=IronViper;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
<elmah>
<errorLog type="Elmah.XmlFileErrorLog, Elmah" logPath="~/App_Data" />
</elmah>
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
</httpModules>
<trace localOnly="false" pageOutput="true" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear />
<add connectionStringName="ApplicationServices" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" />
<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<httpWarmup>
<requests>
<add requestUrl="/" allowedResponseCodes="200-399" warmupContext="" sendMode="Asynchronous" />
</requests>
</httpWarmup>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<appSettings>
</appSettings>
</configuration>
The URL used on the production server is: http://xxxx/IronViperWebInterface/elmah.axd
and on Casini : http://localhost:xxxx/elmah.axd
I tried to change
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
to
<add verb="POST,GET,HEAD" path="IronViperWebInterface/elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
but that don't change anything.
I can't find the problem..
Any idea please ?
Thank you
Looks like this might be your answer:
Elmah not working with asp.net site

ELMAH on MongoDB web interface throw exception

after configure logs to MongoDB using ELMAH on MongoDB nuget package
it successfully log to MongoDB collection but when trying to access the Web interface it gives me the following exception:
Command 'create' failed: a collection 'collectionname' already exists (response: { "note" : "the autoIndexId option is deprecated and
will be removed in a future release", "ok" : 0.0, "errmsg" : "a
collection 'collectionname' already exists", "code" : 48, "codeName" :
"NamespaceExists" })
i don't know why each time it try to create the collection
the web config configuration for elmah:
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.FallbackErrorLogSectionHandler, Elmah.FallbackErrorLog" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
<!--<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />-->
</sectionGroup>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<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>
</system.webServer>
<elmah>
<security allowRemoteAccess="true" />
<errorLog type="Elmah.FallbackErrorLog, Elmah.FallbackErrorLog">
<add type="Elmah.MongoErrorLog, Elmah.MongoDB" connectionStringName="elmah-mongodb" />
<add type="Elmah.XmlFileErrorLog, Elmah" logPath="C:\MyApp\logs\ElmahFallback" />
</errorLog>
</elmah>
<location path="logs" inheritInChildApplications="false">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<authorization>
<!--<allow roles="*" />-->
<allow users="*" />
</authorization>
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH" verb="POST,GET,HEAD" path="logs" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
</handlers>
</system.webServer>
</location>
this error is by MongoDB 3.2 and up decrepted function (related by indexes when you create a new collection), try with 3.0 mongos's version or change the mongo's driver. I'm using this package Install-Package elmah.mongodb in visual studio nuget package console and mongo 3.0 version in c#.net and it's running perfectly.
I hope that it help you!!! good luck.