The requested page is not available for the requested platform. You are viewing the content for Default platform.

Log Files

  • 6 min to read

The Log file records all system and end-user operations during the runtime of an application. Examples of system operations are: loading the model, generating the default model for actions and property editors, and loading model differences. The most common end-user operation is executing an action - pressing a toolbar button, etc. If any operation leads to an error or an exception, the corresponding information is also written to a log file. So, if a problem occurs, the log file makes it easy to track the cause. If you cannot resolve an issue yourself, you can send a log file to our Support Center, to get assistance from Developer Express support engineers.

Log files are not re-written each time you run an application. The new content is added below the previously logged information. Therefore, you can analyze multiple application runs, if needed.

XAF tracing mechanism relies on the standard .NET Framework logging APIs from the System.Diagnostics and related namespaces. By default, the TextWriterTraceListener class writes all application events into the eXpressAppFramework.log file by means of the DevExpress.Persistent.Base.Tracing class. The latter is technically a wrapper above the standard trace listeners. To see how to customize this default tracing mechanism, refer to the MSDN articles linked above and to the Add Custom Log Entries and Customize the Default Tracer Behavior topic.

Log Files Generated at Runtime

The eXpressApp Framework can produce the Windows Forms, ASP.NET and Mobile applications based on the same logic. Each application has its own log file.

The log file location is specified in the application configuration file, by the TraceLogLocation attribute. The following snippet illustrates this.

<configuration>
    <appSettings>
        <!-- ... -->
        <add key="TraceLogLocation" value="ApplicationFolder"/>

The possible TraceLogLocation values are:

Value Description
ApplicationFolder The log file is saved to the application folder. The Windows Forms application saves the log file to a folder where the application executable is located. The ASP.NET and Mobile applications save the log file to a folder where the default.aspx file is located. Ensure that the system account used to run the application has a write permission to this folder.
CurrentUserApplicationDataFolder The log file is saved to the current user ApplicationData folder. In effect for Windows Forms applications only.
None Logging is disabled. It is recommended to use this value in the production environment because there is no log rotation mechanism in XAF.

By default, the log file is called eXpressAppFramework.log. To specify another Windows Forms application log file, open the Program.cs (Program.vb) file located in the Windows Forms application project. Set the LogName property of the Tracing class in the Main method, before an XAF Application object is instantiated. The following code snippet illustrates this.

static class Program {
    // ...
    static void Main() {
        Tracing.LogName = "CustomLogFile";
        // ...
        MySolutionWindowsFormsApplication winApplication = 
            new MySolutionWindowsFormsApplication();
        //...

To specify another ASP.NET application log file, open the Global.asax.cs (Global.asax.vb) file located in the ASP.NET application project. Set the LogName property of the Tracing class in the Session_Start event handler, before an XAF Application object is instantiated. The following code snippet illustrates this.

public class Global : System.Web.HttpApplication {
    // ...        
    protected void Session_Start(Object sender, EventArgs e) {
        Tracing.LogName = "CustomLogFile";
        // ...
        WebApplication.SetInstance(Session, new MySolutionAspNetApplication());
        // ...

To specify another Mobile application log file, open the Global.asax.cs (Global.asax.vb) file located in the Mobile application project. Set the LogName property of the Tracing class in the Session_Start event handler. The following code snippet illustrates this.

public class Global : System.Web.HttpApplication {
    // ...        
    protected void Session_Start(Object sender, EventArgs e) {
        Tracing.LogName = "CustomLogFile";
        // ...

The ".log" extension is added automatically.

You can also specify the log file relative path or absolute path in a similar manner. For instance, you can set the Tracing.LogName property to "Logs\CustomLogFile" or "C:\Logs\CustomLogFile". Ensure that the specified location is accessible. Otherwise, the log file will not be created.

Note

If an attempt is made to write to a log file that is in use, the file name is automatically prefixed by a GUID (Globally Unique Identifier). For instance, it is possible when several XAF applications are running simultaneously. To avoid prefixes, specify a custom log file name for each application.

You can control the detail level of information written into an application log file. To do this, you need to modify the content of the <system.diagnostics> tag within the App.config (for a Windows Forms application) or Web.config file (for a ASP.NET Web and Mobile application). This tag has two entries - one for the eXpressApp Framework itself, and another that controls how eXpress Persistent Objects logs its operations. For both these entries, you can specify five different detail levels:

Level Description
0 Logging is disabled.
1 Only errors are logged.
2 Errors and warning messages are written into the log file.
3 In addition to the previous messages, the system logs detected operations executed by the system, or end-users.
4 Use this level to create the most detailed log files. All Security System loggers (Permission Processors, Middle Tier loggers, security rule loggers) are enabled in this mode.

The following snippet sets the Level 4 for the eXpressApp Framework:

<configuration>
   <system.diagnostics>
      <switches>
         <add name="eXpressAppFramework" value="4" />
         <!--<add name="XPO" value="4" />-->
      </switches>
   </system.diagnostics>
</configuration>

In addition to information written to log files by the system, you can also manually write diagnostics information to log files. To accomplish this, use static methods available via the static DevExpress.Persistent.Base.Tracing.Tracer property. For details on these logging methods, see Add Custom Log Entries and Customize the Default Tracer Behavior.

Log Files Generated for Designers

While working on an XAF application, you may face problems in loading the Application Designer, Module Designer and Model Editor. For any of these designers, log files are generated. Information written to these log files may help you solve the problems raised. The following table details how to find the required log file:

Designer Log File Name Log File Location
Application Designer <ApplicationClassName>.Designer.log <SolutionName>.Win, <SolutionName>.Web or <SolutionName>.Mobile folders, depending on the project the designer failed to invoke
Module Designer <ModuleClassName>.Designer.log <SolutionName>.Module, <SolutionName>.Module.Win, <SolutionName>.Module.Web or <SolutionName>.Mobile folder, depending on the project the designer failed to invoke
Model Editor Model.DesignedDiffs.log or Model.log, depending on whether the Model Editor failed to invoke for a module or application project. <SolutionName>.Module, <SolutionName>.Module.Win, <SolutionName>.Module.Web or <SolutionName>.Mobile folder, depending on the project the designer failed to invoke
See Also