logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityFileLogService

    Unity-specific file logging service that extends UnityLogService with file persistence.
    Writes log entries to persistent file storage using PersistenceUseCases for async file operations and IPathService for file path resolution. Handles exception logging with full stack traces and uses UTF-8 encoding for file output. Provides fallback error logging to Unity Debug.LogError when file operations fail.

    Inheritance
    object
    UnityFileLogService
    Namespace: Serenity.EventDispatcher.Infrastructure.Services
    Assembly: Serenity.UnityFileLogging.Infrastructure.dll
    Syntax
    public class UnityFileLogService : UnityLogService

    Constructors

    UnityFileLogService()

    Declaration
    public UnityFileLogService()

    Methods

    Initialize(CreateLogServiceDTO)

    Initializes Unity file log service with persistence and path service dependencies.
    Casts input DTO to CreateFileLogServiceDTO, validates required dependencies, and calls base Initialize for log formatting configuration.
    Throws ArgumentNullException if persistence or path service dependencies are null.

    Declaration
    public override void Initialize(CreateLogServiceDTO input)
    Parameters
    Type Name Description
    CreateLogServiceDTO input

    CreateFileLogServiceDTO containing persistence and path service dependencies

    Exceptions
    Type Condition
    ArgumentNullException

    Thrown when PersistenceUseCases or PathService are null

    WriteLog(LogEntry)

    Writes log entry to persistent file storage asynchronously with exception handling.
    Checks log enablement, resolves log file path, formats log entry with special handling for exceptions (including full stack traces), converts to UTF-8 bytes, and appends to log file using PersistenceUseCases. Falls back to Unity Debug.LogError if file writing fails to prevent log loss.

    Declaration
    public override void WriteLog(LogEntry entry)
    Parameters
    Type Name Description
    LogEntry entry

    LogEntry containing message, severity, category, tags, and optional exception

    In this article
    © 2026 Serenity. All Rights Reserved