This page is a work in progress and could be pending updates.
server | v5 switch to v4  

Logging

Contents

Logging Framework

Photon uses log4net as a logging framework.

Documentation: https://logging.apache.org/log4net/

Back To Top
 

Log Files And Locations

There are 3 types of log files:

The Unmanaged Photon Socket Server Log

  • Content: Written by the unmanaged "PhotonSocketServer.exe" core. All status messages from Photon's start / stop sequence are logged here, as well as exceptions from the native core (like: bugs in Photon itself, serialization errors from invalid client data and so on).
  • Name: "Photon-{InstanceName}-Timestamp.log"
  • Log Level Configuration: n/a
  • Location: Default is "/bin_WinXXX/log". To change the log file location set the "LogFileLocation" attribute on each Instance node in "PhotonServer.config". The "LogFileLocation" can be either an absolute path or relative to "PhotonSocketServer.exe".

Example:


<Default
    MinimumTimeout="5000"
    MaximumTimeout="30000"
    LogFileLocation="..\MyLogFolder"
>

Back To Top
 

The Managed CLR Log

  • Content: Written by the managed .NET runtime that hosts your application. All status messages from the CLR are logged here (for example: information about loaded .NET applications & assemblies) and ALL unhandled exceptions from your custom .NET applications.
  • Name: "PhotonCLR.log"
  • Log Level Configuration: configure the appropriate log4net appender in "/deploy/bin_WinXXX/Photon.local.log4net".
  • Location: Default is "/bin_WinXXX/log". To change the log file location configure the appropriate log4net appender in "/deploy/bin_WinXXX/Photon.local.log4net". You can use the "Photon:UnmanagedLogDirectory" property, which contains the value of the "LogFileLocation" attribute from "PhotonServer.config".

Example:


<appender name="A1" type="log4net.Appender.RollingFileAppender">
    <file type="log4net.Util.PatternString" value="%property{Photon:UnmanagedLogDirectory}\\PhotonCLR.log" />            
    <!-- snip -->
</appender>

Back To Top
 

The Application Logs

  • Content: each .NET application that is hosted by Photon writes its own application log file. It contains all debug output from the application.
  • Name: "{MyApplication}.log".
  • Log Level Configuration: You can configure the appropriate log4net appender in "/deploy/{MyApplication}/bin/log4net.config".
  • Location: Default is "/deploy/log". To change the log file location configure the appropriate log4net appender in "/deploy/{MyApplication}/bin/log4net.config". You can use the "Photon:ApplicationLogPath" property, which is set to "/deploy/log" per default which can be changed in the Setup() method of your application.
protected override void Setup()
{
    // log4net
    log4net.GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(this.ApplicationRootPath, "log");
    var configFileInfo = new FileInfo(Path.Combine(this.BinaryPath, "log4net.config"));
    if (configFileInfo.Exists)
    {
        LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
        XmlConfigurator.ConfigureAndWatch(configFileInfo);
    }
}
<?xml version="1.0" encoding="utf-8" ?>
<log4net debug="true" update="Overwrite"> 
    <appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender">
        <file type="log4net.Util.PatternString" value="%property{Photon:ApplicationLogPath}\\{MyApplication}.log" />    
        <!-- snip --> 
    </appender>
    <root>
        <!-- <level value="INFO" /> -->
        <!-- <level value="DEBUG" /> -->
        <level value="ALL" />
        <appender-ref ref="LogFileAppender" /> 
    </root>
</log4net>

Back To Top
 

Frequently Asked Questions


To Document Top