I showed it at Wave and share it with all of you: when you use JSON to log, you can log anything, not just strings, you can log a Dictionary, a list, a MemberInfo, even a Databuffer.
First, you nee...
Here is the image for the WriteLogger function from the pdf without the overlaying image, along with the code (or at least my best attempt to transcribe it, haha).
Public Shared Function WriteLogger (ByVal si As SessionInfo, ByVal api As Object, ByRef logger As System.Text.StringBuilder,
Optional ByVal fileName As String = "LOG", Optional ByVal folderName As String = "TestLogs",
Optional ByVal filesuffix As String = Nothing) As String
'Saves log to text file on application database
'
'Parameters
' logger: string builder object with contents of log file
' fileName: optional log file name. defaults to LOG
' folderName: optional log folder destination. defaults to TestLogs
' fileSuffix: optional log file suffix. defaults to system time
'Returns
' filepath of log file
If filesuffix Is Nothing Then
fileSuffix = DateTime.Now.ToString("yyyy-MM-dd_HHmmss")
End If
Dim logFileName As String = fileName & "_" & filesuffix & ".txt"
Dim targetFolder As String = folderName
Dim targetPath As String = "Documents/Public"
'Create folder if it does not exist
Dim folderPath As XFFolderEx = BRApi.FileSystem.GetFolder(si, FileSystemLocation.ApplicationDatabase, targetPath & "/" & targetFolder)
If folderPath Is Nothing Then
BRapi.FileSystem.CreateFullFolderPathIfNecessary(si, FileSystemLocation.ApplicationDatabase, targetPath, targetFolder)
End If
'Create File with logger contents and save in folder
Dim targetDir As String = BRApi.FileSystem.GetFolder(si, FileSystemLocation.ApplicationDatabase, targetPath & "/" & targetFolder).XFFolder.FullName
Dim dbFileInfo As New XFFileInfo(FileSystemLocation.ApplicationDatabase, logFileName, targetDir, XFFileType.Unknown)
dbFileInfo.ContentFileContainsData = True
dbFileInfo.ContentFileExtension = dbFileInfo.Extension
Dim dbFile As New XFFile(dbfileInfo, String.Empty, System.Text.Encoding.UTF8.GetBytes(logger.ToString))
BRApi.FileSystem.InsertOrUpdateFile(si, dbfile)
Return dbFile.FileInfo.FullName
End Function