7

我将 DotNetOpenAuth 与 MVC 4 应用程序一起使用。突然谷歌身份验证失败(MS正在工作)。股票代码这样做:

[AllowAnonymous]
public ActionResult ExternalLoginCallback(string returnUrl)
{
    var result = OAuthWebSecurity.VerifyAuthentication(Url.Action("ExternalLoginCallback", new { ReturnUrl = returnUrl }));
    if (!result.IsSuccessful)
    {
        return RedirectToAction("ExternalLoginFailure");
    }

我知道那result.IsSuccessful是假的,但我怎么知道原因呢?result.Error一片空白。

我还查看了此页面以使用 log4net。我确实在本地开发箱上获得了日志,但在将其部署到远程服务器时却没有。

log4net 网络配置:

<log4net>
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="RelyingParty.log" />
      <appendToFile value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="100KB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date (GMT%date{%z}) [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
    <!-- Setup the root category, add the appenders and set the default level -->
    <root>
      <level value="INFO" />
      <appender-ref ref="RollingFileAppender" />
    </root>
    <!-- Specify the level for some specific categories -->
    <logger name="DotNetOpenAuth">
      <level value="ALL" />
    </logger>
  </log4net>

编辑我也试过 log4net 到一个 sql 数据库,但它仍然没有记录任何东西

4

1 回答 1

3

我终于想通了。我收到的实际错误消息:

Protocol error: This message has a timestamp of 10/23/2012 12:19:33 PM, 
which is beyond the allowable clock skew for in the future. 

在服务器崩溃后发现时区设置不正确。这导致验证/令牌从谷歌端失败。

AdoNetAppender是“不工作”,因为bufferSize设置为 100。将其设置为 1 后,它开始获取日志。这是我正在使用的 adonetappender

  <log4net>
        <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
      <bufferSize value="1" />
      <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <connectionStringName value="CONNECTIONSTRINGNAME" />
      <commandText value="INSERT INTO Log4Net ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)" />
      <parameter>
        <parameterName value="@log_date" />
        <dbType value="DateTime" />
        <layout type="log4net.Layout.RawTimeStampLayout" />
      </parameter>
      <parameter>
        <parameterName value="@thread" />
        <dbType value="String" />
        <size value="255" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%thread" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@log_level" />
        <dbType value="String" />
        <size value="50" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%level" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@logger" />
        <dbType value="String" />
        <size value="255" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%logger" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@message" />
        <dbType value="String" />
        <size value="4000" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%message" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@exception" />
        <dbType value="String" />
        <size value="2000" />
        <layout type="log4net.Layout.ExceptionLayout" />
      </parameter>
    </appender>
    <root>
      <level value="Debug" />
      <appender-ref ref="AdoNetAppender" />
    </root>
    <logger name="DotNetOpenAuth">
      <level value="ALL" />
    </logger>
  </log4net>

bufferSize当您解决问题时,您应该将back 设置为 100。

于 2012-10-23T20:02:44.370 回答