MS Log Parser 2.2 查询错误
MS Log Parser 2.2 Query Error
我正在尝试确定用户是否使用 MS Log Parser 2.2
从 FTP 下载文件
尽管我使用了几个示例查询,但我无法让解析器 SQL 查询继续。
Water Down 解析器查询不起作用:
strSQL = "SELECT date,COUNT(*) AS downloads,c-ip "
strSQL = strSQL & "FROM C:\temp\Log\*.log "
strSQL = strSQL & "WHERE cs-method='RETR' "
strSQL = strSQL & "GROUP BY date,c-ip "
错误:
RecordSet cannot be used at this time [Unknown Error]
问题:
如何创建查询:
- SELECT Date and Time of download
- Where user = 'xxx'
- WHERE RETR = is a download
- WHERE Filename = u_ex150709.log or xxx
也欢迎用 C# 回答
VB.net代码:
Dim rsLP As ILogRecordset = Nothing
Dim rowLP As ILogRecord = Nothing
Dim LogParser As LogQueryClassClass = Nothing
Dim W3Clog As COMW3CInputContextClassClass = Nothing
Dim UsedBW As Double = 0
Dim Unitsprocessed As Integer
Dim strSQL As String = Nothing
LogParser = New LogQueryClassClass()
W3Clog = New COMW3CInputContextClassClass()
Try
strSQL = "SELECT date,COUNT(*) AS downloads,c-ip "
strSQL = strSQL & "FROM C:\temp\Log\*.log "
strSQL = strSQL & "WHERE cs-method='RETR' "
strSQL = strSQL & "GROUP BY date,c-ip "
'run the query against W3C log
rsLP = LogParser.Execute(strSQL, W3Clog)
'Error occurs in the line below
rowLP = rsLP.getRecord()
Just like you I've written tools that leverage LogParser, eg
http://eventanalyser.appointmentsbook.com/
虽然回到 2004 年(使用 .Net 1.1)我没有下载的好处:https://visuallogparser.codeplex.com/
检查他们的源代码,让您的查询在其中运行 (VisualLogParser),然后在您的项目中简单地引用它并享受开源社区的好处。
关于 FTP 吸取的问题,这里是 MSDN 文章:http://blogs.msdn.com/b/robert_mcmurray/archive/2010/09/02/detecting-ftp-leeches-with-logparser.aspx
SELECT date,COUNT(*) AS downloads,c-ip,x-session
FROM *.log
WHERE cs-method='RETR'
GROUP BY date,c-ip,x-session
HAVING COUNT(*) > 100
当查看我创建的动态创建的 GUI 时,您的查询确实很突出,您在文件路径周围缺少单引号:
strSQL = strSQL & "FROM C:\temp\Log\*.log "
试试这个:
strSQL = strSQL & "FROM 'C:\temp\Log\*.log' "
(并使用 StringBuilder,而不是字符串连接...只是为了养成最佳实践的习惯)
根据:
If the quotes don't solve the problem first go, then try a single log file rather than the
wildcard *.log
to narrow down on the syntax error. LogParser isn't
designed to be helpful at diagnosing problem queries, instead Gabriele
Giuseppini designed it to be fast, very fast!
我正在尝试确定用户是否使用 MS Log Parser 2.2
从 FTP 下载文件尽管我使用了几个示例查询,但我无法让解析器 SQL 查询继续。
Water Down 解析器查询不起作用:
strSQL = "SELECT date,COUNT(*) AS downloads,c-ip "
strSQL = strSQL & "FROM C:\temp\Log\*.log "
strSQL = strSQL & "WHERE cs-method='RETR' "
strSQL = strSQL & "GROUP BY date,c-ip "
错误:
RecordSet cannot be used at this time [Unknown Error]
问题:
如何创建查询:
- SELECT Date and Time of download
- Where user = 'xxx'
- WHERE RETR = is a download
- WHERE Filename = u_ex150709.log or xxx
也欢迎用 C# 回答
VB.net代码:
Dim rsLP As ILogRecordset = Nothing
Dim rowLP As ILogRecord = Nothing
Dim LogParser As LogQueryClassClass = Nothing
Dim W3Clog As COMW3CInputContextClassClass = Nothing
Dim UsedBW As Double = 0
Dim Unitsprocessed As Integer
Dim strSQL As String = Nothing
LogParser = New LogQueryClassClass()
W3Clog = New COMW3CInputContextClassClass()
Try
strSQL = "SELECT date,COUNT(*) AS downloads,c-ip "
strSQL = strSQL & "FROM C:\temp\Log\*.log "
strSQL = strSQL & "WHERE cs-method='RETR' "
strSQL = strSQL & "GROUP BY date,c-ip "
'run the query against W3C log
rsLP = LogParser.Execute(strSQL, W3Clog)
'Error occurs in the line below
rowLP = rsLP.getRecord()
Just like you I've written tools that leverage LogParser, eg http://eventanalyser.appointmentsbook.com/
虽然回到 2004 年(使用 .Net 1.1)我没有下载的好处:https://visuallogparser.codeplex.com/
检查他们的源代码,让您的查询在其中运行 (VisualLogParser),然后在您的项目中简单地引用它并享受开源社区的好处。
关于 FTP 吸取的问题,这里是 MSDN 文章:http://blogs.msdn.com/b/robert_mcmurray/archive/2010/09/02/detecting-ftp-leeches-with-logparser.aspx
SELECT date,COUNT(*) AS downloads,c-ip,x-session
FROM *.log
WHERE cs-method='RETR'
GROUP BY date,c-ip,x-session
HAVING COUNT(*) > 100
当查看我创建的动态创建的 GUI 时,您的查询确实很突出,您在文件路径周围缺少单引号:
strSQL = strSQL & "FROM C:\temp\Log\*.log "
试试这个:
strSQL = strSQL & "FROM 'C:\temp\Log\*.log' "
(并使用 StringBuilder,而不是字符串连接...只是为了养成最佳实践的习惯)
根据:
If the quotes don't solve the problem first go, then try a single log file rather than the wildcard
*.log
to narrow down on the syntax error. LogParser isn't designed to be helpful at diagnosing problem queries, instead Gabriele Giuseppini designed it to be fast, very fast!