IIS FTP 7.5 扩展性(IFtpLogProvider 并将 FTP 故障记录到事件日志中)
任何非常熟悉 IIS 中 FTP 7.5 可扩展性的人都知道我可能做错了什么吗?
我在使 IFtpLogProvider 的实现正常工作以进行自定义日志记录时遇到严重困难。我想做的就是将超出静态阈值的故障记录到事件日志中,并经常进行垃圾收集。我尝试过使用通用字典和提供程序,但没有成功,现在即使是这个简单的代码我也无法工作。提供程序甚至没有在下面的代码存根中创建事件日志(或者如果我事先创建它,则使用它)。所以现在我很迷茫。
在从 VS 中对程序集进行签名后,我按照说明注册该程序集,并且我可以确认它已添加到 GAC 中。通过“注册自定义提供程序”选项将其添加到 IIS 7.5 似乎也可以。
任何有关具体建议的帮助将不胜感激,因为即使有了罗伯特·麦克默里(Robert McMurray)提供的一套出色的教程,我仍然遇到这些问题。顺便说一句,我正在 2008 R2 机器上运行它,使用托管代码的界面。
存根如下:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration.Provider;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Diagnostics.Eventing;
using System.Text;
using Microsoft.Web.FtpServer;
using System.IO;
public class test: BaseProvider, IFtpLogProvider
{
void IFtpLogProvider.Log(FtpLogEntry loggingParameters)
{
if (!EventLog.SourceExists("TEST"))
{
EventLog.CreateEventSource("TEST", "TEST");
}
// Just trying to get anything into this log, like a list of
// USER attempts or something
EventLog.WriteEntry("TEST", loggingParameters.Command);
}
// Mark an IP address for banning.
private void BanAddress(string ipAddress)
{
EventLog.WriteEntry("TEST", ipAddress, EventLogEntryType.Warning, 9010);
}
}
Anyone pretty familiar with FTP 7.5 extensibility in IIS know what I might be doing wrong?
I am having serious trouble getting an implementation of IFtpLogProvider to work correctly for custom logging. All I want to do is log failures beyond a static threshold to the event log, and have garbage collection every so often. I've tried working with a generic dictionary and the provider with no luck, and now even this simple bit of code I can't get working. The provider is not even creating the event log in the code stub below (or using it if I create it beforehand). So now I am deeply confused.
I follow the instructions to register the assembly after it is signed from within VS and I can confirm that it is added to the GAC. Adding it to IIS 7.5 via the Register Custom Providers option seems to be fine, too.
Any help with specific suggestions would be greatly appreciated, as even with the excellent set of tutorials by Robert McMurray I am still having these issues. I am running this on a 2008 R2 box, by the way, using the interface for managed code.
Stub below:
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration.Provider;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Diagnostics.Eventing;
using System.Text;
using Microsoft.Web.FtpServer;
using System.IO;
public class test: BaseProvider, IFtpLogProvider
{
void IFtpLogProvider.Log(FtpLogEntry loggingParameters)
{
if (!EventLog.SourceExists("TEST"))
{
EventLog.CreateEventSource("TEST", "TEST");
}
// Just trying to get anything into this log, like a list of
// USER attempts or something
EventLog.WriteEntry("TEST", loggingParameters.Command);
}
// Mark an IP address for banning.
private void BanAddress(string ipAddress)
{
EventLog.WriteEntry("TEST", ipAddress, EventLogEntryType.Warning, 9010);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我遇到了以下问题:
1) 我在 IIS 中注册此程序集时遇到了不正确的类名:
FtpLogging.FtpLogDemo,FtpLoggingDemo,version=1.0.0.0,Culture =neutral,PublicKeyToken=
2) 我在注册程序集时没有严格遵循 Robert 的建议。我选中了该复选框,这将其保留为身份验证提供程序,而此代码示例不是。相反,我启用了基本身份验证,禁用了匿名身份验证(在我的情况下),并取消选中教程中提到的框 - “清除提供程序列表中的 FtpLoggingDemo 复选框。”
3) 我没有使用 AppCmd(或直接修改 applicationHost.config 中的相应部分)来更新 applicationHost.config 中的自定义提供程序部分
执行这三件事解决了问题。
I had the following issues:
1) I had an incorrect class name in my registration of this assembly in IIS:
FtpLogging.FtpLogDemo,FtpLoggingDemo,version=1.0.0.0,Culture=neutral,PublicKeyToken=
2) I did not closely follow Robert's advice when registering the assembly. I left the checkbox checked, and this kept it as an authentication provider, which this code sample is not. I instead left basic auth enabled, disabled anonymous auth (in my case), and unchecked the box mentioned in the tutorial -- 'Clear the FtpLoggingDemo check box in the providers list.'
3) I was not using AppCmd (or modifying the appropriate section in applicationHost.config directly) to update the custom providers section in applicationHost.config
Doing these three things fixed the issue.