> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/scene-fusion/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sflogfile.md).

# Class sfLogFile

Namespace: [KS.SceneFusion.Client.Unity.Editor](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor.md)\
Assembly: KSUnity-Source.dll

This class is used to write ksLog messages to a log file.

```csharp
public class sfLogFile
```

#### Inheritance

object ← [sfLogFile](/scene-fusion/api-reference/ks.scenefusion.client.unity.editor/ks.scenefusion.client.unity.editor.sflogfile.md)

## Constructors

### sfLogFile() <a href="#ks_scenefusion_client_unity_editor_sflogfile__ctor" id="ks_scenefusion_client_unity_editor_sflogfile__ctor"></a>

Constructor

```csharp
public sfLogFile()
```

## Properties

### IsLoggingToSessionLog <a href="#ks_scenefusion_client_unity_editor_sflogfile_isloggingtosessionlog" id="ks_scenefusion_client_unity_editor_sflogfile_isloggingtosessionlog"></a>

Are we logging to a session log file?

```csharp
public bool IsLoggingToSessionLog { get; }
```

#### Property Value

bool

## Methods

### Close() <a href="#ks_scenefusion_client_unity_editor_sflogfile_close" id="ks_scenefusion_client_unity_editor_sflogfile_close"></a>

Flush and close the current log file

```csharp
public void Close()
```

### EndSessionLog() <a href="#ks_scenefusion_client_unity_editor_sflogfile_endsessionlog" id="ks_scenefusion_client_unity_editor_sflogfile_endsessionlog"></a>

Ends session logging.

```csharp
public void EndSessionLog()
```

### \~sfLogFile() <a href="#ks_scenefusion_client_unity_editor_sflogfile_finalize" id="ks_scenefusion_client_unity_editor_sflogfile_finalize"></a>

Destructor

```csharp
protected ~sfLogFile()
```

### LogUnityException(string, string, LogType) <a href="#ks_scenefusion_client_unity_editor_sflogfile_logunityexception_system_string_system_string_unityengi" id="ks_scenefusion_client_unity_editor_sflogfile_logunityexception_system_string_system_string_unityengi"></a>

Unity log handler that writes exceptions to the log file.

```csharp
public void LogUnityException(string message, string stackTrace, LogType type)
```

#### Parameters

`message` string

`stackTrace` string

stackTrace of log statement or exception.

`type` LogType

type of log. The log will be ignored if this is not Exception.

### Open(string) <a href="#ks_scenefusion_client_unity_editor_sflogfile_open_system_string" id="ks_scenefusion_client_unity_editor_sflogfile_open_system_string"></a>

Open a file to receive log messages. If the file is already open, then return. If a file is open and it does not match the requested file, then close the current file and open a new one.

```csharp
public void Open(string filePath)
```

#### Parameters

`filePath` string

### RemoveOldLogFiles(string) <a href="#ks_scenefusion_client_unity_editor_sflogfile_removeoldlogfiles_system_string" id="ks_scenefusion_client_unity_editor_sflogfile_removeoldlogfiles_system_string"></a>

Deletes the oldest log files until there are no more than the log history size.

```csharp
public static void RemoveOldLogFiles(string path)
```

#### Parameters

`path` string

path to folder to delete logs in.

### RenameSessionLog(ref string) <a href="#ks_scenefusion_client_unity_editor_sflogfile_renamesessionlog_system_string" id="ks_scenefusion_client_unity_editor_sflogfile_renamesessionlog_system_string"></a>

Renames the current session log file. Does nothing if the log type is not LogType.SESSION\_LOG.

```csharp
public void RenameSessionLog(ref string sessionLogId)
```

#### Parameters

`sessionLogId` string

determines the new name of the log file. If a log already exists with this id, a '.' followed by a number will be appended to make a unique log file path.

### SendLog(sfIWebService, sfSessionInfo) <a href="#ks_scenefusion_client_unity_editor_sflogfile_sendlog_ks_scenefusion_client_sfiwebservice_ks_scenefus" id="ks_scenefusion_client_unity_editor_sflogfile_sendlog_ks_scenefusion_client_sfiwebservice_ks_scenefus"></a>

Sends log file to server

```csharp
public void SendLog(sfIWebService webService, sfSessionInfo sessionInfo)
```

#### Parameters

`webService` [sfIWebService](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfiwebservice.md)

`sessionInfo` [sfSessionInfo](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfsessioninfo.md)

sessionInfo the logs are for. Null if the logs are not for a session.

### SendLog(sfIWebService, sfSessionInfo, string) <a href="#ks_scenefusion_client_unity_editor_sflogfile_sendlog_ks_scenefusion_client_sfiwebservice_ks_scenefus" id="ks_scenefusion_client_unity_editor_sflogfile_sendlog_ks_scenefusion_client_sfiwebservice_ks_scenefus"></a>

Sends log file to server with call back

```csharp
public void SendLog(sfIWebService webService, sfSessionInfo sessionInfo, string log)
```

#### Parameters

`webService` [sfIWebService](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfiwebservice.md)

`sessionInfo` [sfSessionInfo](/scene-fusion/api-reference/ks.scenefusion.client/ks.scenefusion.client.sfsessioninfo.md)

sessionInfo the logs are for. Null if the logs are not for a session.

`log` string

### StartSessionLog(string) <a href="#ks_scenefusion_client_unity_editor_sflogfile_startsessionlog_system_string" id="ks_scenefusion_client_unity_editor_sflogfile_startsessionlog_system_string"></a>

Starts session loggging.

```csharp
public void StartSessionLog(string sessionLogId)
```

#### Parameters

`sessionLogId` string

identifies which log file to log to.

### Write(Level, string, string) <a href="#ks_scenefusion_client_unity_editor_sflogfile_write_ks_reactor_kslog_level_system_string_system_strin" id="ks_scenefusion_client_unity_editor_sflogfile_write_ks_reactor_kslog_level_system_string_system_strin"></a>

Write data on to the output stream

```csharp
public void Write(ksLog.Level level, string channel, string message)
```

#### Parameters

`level` ksLog.Level

`channel` string

`message` string

### Write(Level, string, string, Exception, object) <a href="#ks_scenefusion_client_unity_editor_sflogfile_write_ks_reactor_kslog_level_system_string_system_strin" id="ks_scenefusion_client_unity_editor_sflogfile_write_ks_reactor_kslog_level_system_string_system_strin"></a>

Write data on to the output stream and inlcude exceptions

```csharp
public void Write(ksLog.Level level, string channel, string message, Exception e, object context)
```

#### Parameters

`level` ksLog.Level

`channel` string

`message` string

`e` Exception

`context` object

object related to this message.
