Enabling/Disabling Logging To Files

You can control whether log messages are saved to a file using the LogInfoToFile property of the Files object in the Settings object of the Log class.

Here's an example of how you can enable or disable file logging in your Unity project:

using UnityEngine;
using CatLog;

public class CustomLogBehaviour : MonoBehaviour
{
    private void Start()
    {
        // Disable logging info logs to files
        Log.Settings.Files.LogInfoToFile = false;
        Log.Info("A message, this will not be logged to file.");
        
        // Enable logging to files
        Log.Settings.Files.LogInfoToFile = true;
        Log.Info("A message, this will be logged to file.");
    }
}

With this code, you can easily turn file logging on or off, depending on your needs. This can be useful if you want to temporarily stop logging to files for debugging purposes or to conserve disk space.

Last updated