We are using log4net to log our site and it is working great but there is one
thing we are not able to solve and that is that many 404 request also logs
as a 500 error.
------------------------------------------------------------------------------------------------------
For example the request for a image as this address (that does not exist):
http://www.lernia.se/Global/Imagebilder/Toppbilder%20utbildningssida%20(produktblad%20mm)%20460x283/5778.jpg
Gives a 404 return from the server but also this error in the errorlog:
1.2.5 Unhandled exception in ASP.NET

System.Web.HttpException (0x80004005): Not Found.
   at EPiServer.Web.StaticFileHandler.ProcessRequest(HttpContext context)
   at
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)

------------------------------------------------------------------------------------------------------
Another example is the request for a aspx-page that does not exist:
http://www.lernia.se/Pages/GoogleMapPage.aspx?LatLong=59.333124,18.064613
Gives a 404 return but logs this in the errorlog
1.2.5 Unhandled exception in ASP.NET

System.Web.HttpException (0x80004005): The file '/Pages/GoogleMapPage.aspx'
does not exist.
   at
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath
virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean
allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   at
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext
context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp,
Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean
ensureIsUpToDate)
   at
System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath
virtualPath, HttpContext context, Boolean allowCrossApp, Boolean
throwIfNotFound)
   at
System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath
virtualPath, Type requiredBaseType, HttpContext context, Boolean
allowCrossApp)
   at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context,
String requestType, VirtualPath virtualPath, String physicalPath)
   at
System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously)
------------------------------------------------------------------------------------------------------

The config we are using looks like this:
<?xml version="1.0" encoding="utf-8"?>
<log4net>
  
  
  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
    <file value="D:\Logs\Errors.log" />
    <encoding value="utf-8" />
    <staticLogFileName value="true"/>
    <datePattern value=".yyyyMMdd.'log'" />
    <rollingStyle value="Date" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <appendToFile value="true" />
    <maximumFileSize value="5000KB" />
    <maxSizeRollBackups value="10" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %identity
%property{log4net:HostName} %type.%method: %message%newline%exception" />
    </layout>
  </appender>
  <appender name="EpiRollingFile"
type="log4net.Appender.RollingFileAppender">
    <file value="D:\Logs\EPiserverErrors.log" />
    <encoding value="utf-8" />
    <staticLogFileName value="true"/>
    <datePattern value=".yyyyMMdd.'log'" />
    <rollingStyle value="Date" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <appendToFile value="true" />
    <maximumFileSize value="5000KB" />
    <maxSizeRollBackups value="10" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %-5level %identity
%property{log4net:HostName} %type.%method: %message%newline%exception" />
    </layout>
  </appender>
  
  <logger name="ActiveSolution" additivity="false">
    <level value="INFO" />
    <appender-ref ref="RollingFile" />
  </logger>
  <logger name="LerniaSE.Web.Pages.WebbCV" additivity="false">
    <level value="ERROR" />
    <appender-ref ref="RollingFile" />
  </logger>
  
  <logger name="EPiServer" additivity="false">
    <level value="ERROR" />
    <appender-ref ref="EpiRollingFile" />
  </logger>
  <logger name="EPiServer.Core.OptimisticCache" additivity="false">
    <level value="ERROR" />
  </logger>
  <logger name="EPiServer.Core.ContentProvider" additivity="false">
    <level value="ERROR" />
  </logger>
  <logger name="EPiServer.Data.Dynamic.Providers.DbDataStoreProvider"
additivity="false">
    <level value="ERROR" />
  </logger>
  <logger name="EPiServer.Data.Providers.SqlDatabaseHandler"
additivity="false">
    <level value="ERROR" />
  </logger>
  <logger name="EPiServer.Data.Providers.ConnectionContext"
additivity="false">
    <level value="ERROR" />
  </logger>

  <logger name="NHibernate" additivity="false">
    <level value="ERROR" />
  </logger>
  
  <root>
    <level value="ERROR" />
    <appender-ref ref="RollingFile" />
  </root>
</log4net>

I hope someone has any clue how to get these 404 pages not to report as a
500-error since it filling up our logfiles and hiding the real errors.

Sincerely

Henrik Fransas





--
View this message in context: 
http://apache-logging.6191.n7.nabble.com/404-reguests-logs-as-500-errors-tp44797.html
Sent from the Log4net - Dev mailing list archive at Nabble.com.

Reply via email to