Log Files
- 7 minutes to read
XAF writes information about runtime errors and exceptions to log files. Log files also record all system and user operations during application runtime. XAF uses two types of log files – runtime and design-time.
If a problem occurs, you can use log files to find the cause. You can also send the log file to our Support Center to get assistance from DevExpress support engineers.
For a number of log files, you can control the level of detail, change the file location, or add custom information.
The XAF trace mechanism relies on standard .NET logging APIs from System.Diagnostics and related namespaces. The DevExpress.Persistent.Base.Tracing
class is a wrapper on the standard trace listeners. The DevExpress.Persistent.Base.Tracing
class uses the TextWriterTraceListener class to write all application events into a log file. Refer to the following topic for more information on how to customize the default trace mechanism: Add Custom Log Entries and Customize the Default Tracer Behavior.
Tip
Use the DevExpress.Persistent.Base.Tracing.LogSensitiveData
property to control sensitive data logging. For more information, refer to the following breaking change ticket: Core - Sensitive data is removed from log files.
Default Log File Names and Locations
Log Files Generated at Runtime
The default log file name is eXpressAppFramework.log. The table below contains the default location for log files generated at runtime.
Platform | The Default Log File Location |
---|---|
WinForms | A folder with the executable file. |
ASP.NET Core Blazor | A folder with the executable file. |
ASP.NET Web Forms | A folder with the Default.aspx file. |
Log Files Generated for Designers
The XAF application creates log files for the following designers: the Application Designer, Module Designer, and Model Editor.
Application Designer (.NET Framework)
- <SolutionName>.Win\<ApplicationClassName>.Designer.log
- <SolutionName>.Web\<ApplicationClassName>.Designer.log
Module Designer (.NET Framework)
- <SolutionName>.Module\<ModuleClassName>.Designer.log
- <SolutionName>.Module.Win\<ModuleClassName>.Designer.log
- <SolutionName>.Module.Web\<ModuleClassName>.Designer.log
Model Editor (All Platforms)
- <SolutionName>.Module\Model.DesignedDiffs.log
- <SolutionName>.Module.Win\Model.DesignedDiffs.log
- <SolutionName>.Module.Web\Model.DesignedDiffs.log
- <SolutionName>.Win\Model.log
- <SolutionName>.Web\Model.log
- <SolutionName>.Blazor.Server\Model.log
Model Editor (.NET 6)
All files in the %USERPROFILE%\AppData\Roaming\eXpressAppFramework\ folder.
Log File Generated in Azure
XAF applications deployed to Azure App Service generate a log file with the eXpressAppFramework.log name. Follow the steps below to find this file:
Open the Azure portal. On the App Services page, select your application service and click Development Tools | App Service Editor (Preview):
Click Go –> and navigate to the WWWROOT section:
Change the Log File Location and Name
Use the TraceLogLocation Attribute to Change the Location in WinForms and Web Forms Applications (.NET Framework and .NET)
WinForms and Web Forms application configuration files use the TraceLogLocation
attribute to specify the log file location.
File: MySolution.Win\App.config, MySolution.Web\Web.config
<configuration>
<appSettings>
<!-- ... -->
<add key="TraceLogLocation" value="ApplicationFolder"/>
<!-- ... -->
</appSettings>
</configuration>
The TraceLogLocation
values:
Value | Description |
---|---|
ApplicationFolder |
XAF stores the log file in the application folder. WinForms applications save the log file to the folder with the executable file. ASP.NET Web Forms applications save the log file to the folder with the default.aspx file. Ensure that the system account used to run the application has write permission to this folder. |
CurrentUserApplicationDataFolder |
XAF saves the log file to the current user ApplicationData folder. You can use this option only in WinForms applications. |
None |
Logging is disabled. Use this value in the production environment since XAF does not support log rotation. |
Use the LogName Property to Change the Name and Location (.NET Framework and .NET)
You can change the default log file name in code before XAF Application object creation. Set the Tracing.LogName
property to a new file name. The .log extension is added automatically.
WinForms
File: MySolution.Win\Program.cs (MySolution.Win\Program.vb)
static class Program {
// ...
static void Main() {
Tracing.LogName = "CustomLogFile";
// ...
MySolutionWindowsFormsApplication winApplication =
new MySolutionWindowsFormsApplication();
//...
ASP.NET Web Forms
File: MySolution.Web\Global.asax.cs (Global.asax.vb)
public class Global : System.Web.HttpApplication {
// ...
protected void Session_Start(Object sender, EventArgs e) {
Tracing.LogName = "CustomLogFile";
// ...
WebApplication.SetInstance(Session, new MySolutionAspNetApplication());
// ...
ASP.NET Core Blazor and Web API
File: MySolution.Blazor.Server\Program.cs, MySolution.WebApi\Program.cs
namespace MySolution.Blazor.Server {
public class Program : IDesignTimeApplicationFactory {
// ...
public static int Main(string[] args) {
Tracing.LogName = "CustomLogFile";
// ...
IHost host = CreateHostBuilder(args).Build();
//...
}
}
}
You can also change the file location in the Tracing.LogName
property. This property accepts the following values:
- A relative path to the log file. For example, Logs\CustomLogFile.
- An absolute path to the log file. For example, C:\Logs\CustomLogFile.
If the specified location is not accessible, XAF does not create the log file.
Note
If XAF tries to write to a log file that is in use, a new log file is created and its name has the GUID prefix. Set a custom log file name for each application to avoid prefixes.
Change the Log File Detail Level
You can control how detailed log file information is. Use numbers to specify five different detail levels in WinForms and ASP.NET Web Forms projects. Utilize the LogLevel enumeration to set the log detail level in ASP.NET Core Blazor and Web API applications.
Level | Blazor and Web API Level | Description |
---|---|---|
0 | LogLevel.None |
Logging is disabled. |
1 | LogLevel.Critical , LogLevel.Error |
The log file records only errors. |
2 | LogLevel.Warning |
The log file records errors and warning messages. |
3 | LogLevel.Information |
In addition to the levels mentioned above, the log file records system and user operations. |
4 | LogLevel.Debug , LogLevel.Trace |
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. |
Note
We recommend log file detail levels 3 and 4 for debugging purposes only because logging reduces performance.
WinForms and Web Forms (.NET Framework)
Edit <system.diagnostics>
tag content in App.config (for WinForms applications) or Web.config (for ASP.NET Web Forms applications). This tag has two entries: eXpressAppFramework
and XPO
. You can specify different detail levels for them.
File: MySolution.Win\App.config, MySolution.Web\Web.config
<configuration>
<system.diagnostics>
<switches>
<add name="eXpressAppFramework" value="4" />
<!--<add name="XPO" value="4" />-->
</switches>
</system.diagnostics>
</configuration>
WinForms (.NET)
Edit <appSettings>
tag content in the App.config file.
File: MySolution.Win\App.config
<configuration>
<!-- ... -->
<appSettings>
<!-- ... -->
<add key="eXpressAppFrameworkTraceLevel" value="4"/>
</appSettings>
</configuration>
ASP.NET Core Blazor and Web API (.NET)
You can specify different log detail levels for different namespaces in the appsettings.json file. The following code sets the Debug
log detail level for the DevExpress.ExpressApp
namespace:
File: MySolution.Blazor.Server\appsettings.json (appsettings.Development.json), MySolution.WebApi\appsettings.json (appsettings.Development.json)
// ...
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"DevExpress.ExpressApp": "Debug"
}
},
// ...
Add Custom Information to Log Files
You can write diagnostic information to a log file. Use static methods from the DevExpress.Persistent.Base.Tracing
class for this purpose. See the following topic for details: Add Custom Log Entries and Customize the Default Tracer Behavior.
Log XPO SQL Queries (.NET)
For more information on how to log SQL queries in .NET applications that use XPO, refer to the following topic: How to Log SQL Queries.
Disable Logging
Use the TraceLogLocation Attribute in WinForms and Web Forms Applications (.NET Framework and .NET)
Set the TraceLogLocation
attribute to None
to disable logging.
File: MySolution.Win\App.config, MySolution.Web\Web.config
<configuration>
<appSettings>
<!-- ... -->
<add key="TraceLogLocation" value="None"/>
<!-- ... -->
</appSettings>
</configuration>
Use the <system.diagnostics> Tag in WinForms and Web Forms Applications (.NET Framework)
Use <system.diagnostics>
tag content in App.config (for WinForms) or Web.config (for ASP.NET Web Forms) to disable logging. Set the log file detail level to 0
:
File: MySolution.Win\App.config, MySolution.Web\Web.config
<configuration>
<system.diagnostics>
<switches>
<add name="eXpressAppFramework" value="0" />
<!--<add name="XPO" value="0" />-->
</switches>
</system.diagnostics>
</configuration>
Use the <appSettings> Tag in WinForms Applications (.NET)
Set the log file detail level to 0
to disable logging. Use the following content within the <appSettings>
tag:
File: MySolution.Win\App.config
<configuration>
<!-- ... -->
<appSettings>
<!-- ... -->
<add key="eXpressAppFrameworkTraceLevel" value="0"/>
</appSettings>
</configuration>
ASP.NET Core Blazor and Web API
Set the log level to None
in the appsettings.json file for the DevExpress.ExpressApp
namespace to disable logging:
File: MySolution.Blazor.Server\appsettings.json (appsettings.Development.json), MySolution.WebApi\appsettings.json (appsettings.Development.json)
// ...
"Logging": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information",
"DevExpress.ExpressApp": "None"
},
// ...