Topic "XML Logging"

Author Message
GTSageDev
[View user's profile]

Joined: 2012-11-14
Posts: 7
Location: United Kingdom
If possible, I'd like to retain the WinSCP XML log, preferably not in %TEMP%. Is there a way of configuring WinSCP.Session to use a specific XMLLog path and not delete it when the session is disposed?

Apologies if this has been asked before - I have looked! I realise this may not be simple, as the assembly uses the XML log to see what's going on in WinsSCP.

Thanks for a really useful bit of software; I wish I had found it earlier - System.Net.FtpWebRequest does have its limitations!

Using WinScp.dll v1.0.2.2735
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Thanks for your post.

This request has been added to the tracker:
https://winscp.net/tracker/show_bug.cgi?id=942

Meanwhile you can make a copy of the log just before calling Session.Dispose().
_________________
Martin Prikryl
GTSageDev
[View user's profile]

Joined: 2012-11-14
Posts: 7
Location: United Kingdom
This VB code will close a WinSCP session, saving the XML log to xmlSavePath
Code:

Imports System.IO
Imports System.Reflection

Sub EndWinScpSession(ByVal ftpSession As WinSCP.Session, ByVal xmlSavePath As String)
        'Close the WinSCP session, saving the XML log file to xmlSavePath
        Dim piXmlLogPath As PropertyInfo = GetType(WinSCP.Session).GetProperty("XmlLogPath", BindingFlags.NonPublic Or BindingFlags.Instance)
        Dim xmlLogPath As String = piXmlLogPath.GetValue(ftpSession, Nothing)
        piXmlLogPath.SetValue(ftpSession, Nothing, Nothing) 'this prevents the xml log being deleted by WinSCP
        ftpSession.Dispose()    'this is necessary to complete the XML log
        'copy the xml log where we want it and then delete the original
        Dim fi As New FileInfo(xmlLogPath)
        fi.CopyTo(xmlSavePath, True)
        fi.Delete()
End Sub
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License