# Function Reference

# _FileWriteLog

Writes current date, time and the specified text to a log file

#include <File.au3>
_FileWriteLog ( $sLogPath, $sLogMsg [, $iFlag = -1] )

## Parameters

$sLogPath | Path of the file to write to, or a file handle returned from FileOpen().
$sLogMsg | Message to be written to the log file
$iFlag | [optional] Flag that defines if $sLogMsg will be written to the end of file, or to the beginning. If $iFlag = -1 (default) $sLogMsg will be written to the end of file. Otherwise $sLogMsg will be written to beginning of file.

## Return Value

Success: | 1.
Failure: | 0 and sets the @error flag to non-zero.
@error: | 1 - Error opening specified file 2 - File could not be written to
@extended: | 1 if trying to write at the beginning using file handle

## Example

### Example 1

    ; Open the logfile in write mode.

    #include <File.au3>

    Local $hFile = FileOpen(@TempDir & "\Example.log", 1)

    _FileWriteLog($hFile, "Text 1") ; Write to the logfile passing the filehandle returned by FileOpen.
    FileClose($hFile) ; Close the filehandle to release the file.

### Example 2

    ; Write to the logfile passing the filepath.

    #include <File.au3>

    _FileWriteLog(@TempDir & "\Example.log", "Text 2")