Copyright ©2025 Fabric | Xytech Help Document Version 1.13
Need Help? Start Here — Welcome to Xytech Help | Xytech Basics | Xytech Notable Features | Using the Help - Best Practices | Xytech Support Web Site
Xytech Trace Logging
Xytech includes a very powerful logging feature called Trace Logging. This feature allows you to understand how Xytech is behaving or why it faults by capturing information about the operating environment. You can also correlate faults and processing across all components of the application, such as operation calls, code exceptions, warnings, and other significant processing events.
Use XyProcessLogFactory.Get(XyProcessLogType) to return an instance of a custom wrapper class that creates a System.Diagnostics.TraceSource. The IXyProcessLog.TraceEvent() method is used to log to the TraceSource. The Xytech.Custom component is used for site-specific DLLs and Xytech.Server is used for any logging that needs to be done on the Xytech demon. To leverage the settings, sources must be defined in the Xytech demon configuration file. When defined, the settings perform the following:
- Set traces to autoflush using the trace element (for increased performance, set useGlobalLock="false").
- Create a switch named "Everything" that sets the value = All. Valid values are Off, Error, Warning, Info, Verbose, and All. Each setting signifies the maximum Trace Event Level Type to “listeners” defined under the source.
- Create a source named Xytech.Server.
- In the listeners element, create a listener using Microsoft.VisualBasic.Logging.FileLogTraceListener. This listener creates log files similar to how IIS creates log files (daily files created).
- Add a filter element to this listener to only show a maximum level of Error to the log file.
- Create a source named Xytech.Custom.
- In the listeners element, create a listener using System.Diagnostics.TextWriterTraceListener. This listener creates log files to a given location.
- In the listeners element, create a listener using System.Diagnostics.EventLogTraceListener. This listener creates an entry to the Windows Event Viewer. Currently, initializeData contains the name of the Event Viewer to write to. Additionally, a filter element is used to override the maximum filter set by the "Everything" switch. The result would be that only Errors will be forwarded to the Event Viewer instead of every message.
- The <remove name="Default" /> tag is used to remove the default listener in the created sources. Based on documentation, the default listener forwards to Windows’ OutputDebugString.
- The traceOutputOptions attribute is used to append additional information to each trace write. The other options that can be added (using a comma delimited string) are the following: DateTime, Timestamp, ProcessId, ThreadId, and Callstack.
ACTIVATING TRACE LOGGING ON THE MEDIAPULSE DEMON
Add the following code inside the configuration node of the Xenetdemon.exe.config file to turn on file logging on the Xytech demon:
<system.diagnostics>
<trace autoflush="true" useGlobalLock="false" />
<sources>
<source name="Xytech.Server" switchName="Everything">
<listeners>
<!--logfilecreationschedule: Determines which date to include in the names of the log files.
Values:
Daily: Include the current date in the log file name.
None: Single file. Do not include the date in the log file name.
Weekly: Include the first day of the current week in the log file name. The week starts on Saturday.
-->
<!--location: sets location for the log files.
Values:
CommonApplicationDirectory: The path for the application data that is shared among all users, with the format:
BasePath\CompanyName\ProductName\ProductVersion
A typical value for BasePath is: C:\Documents and Settings\All Users\Application Data
The values of CompanyName, ProductName, and ProductVersion come from the assembly.
ExecutableDirectory: The path for the executable file that started the application.
LocalUserApplicationDirectory: The path for the application data of a user, with the format:
BasePath\CompanyName\ProductName\ProductVersion
A typical value for BasePath is: C:\Documents and Settings\username\Application Data
The values of CompanyName, ProductName, and ProductVersion come from the assembly.
TempDirectory: The path of the current system's temporary folder.
Custom: If the string specified by CustomLocation is not empty, then use it as the path; otherwise use the path for the application data of a user.
-->
<!--basefilename: sets the base name for the log files, which is used to create the full log-file name.
The base name for the log files. The default is the application's product name.
-->
<!--customlocation: sets the log file directory when the Location property is set to Custom.
The name of the log-file directory. The default setting for this property is the user's directory for application data.
-->
<!--traceOutputOptions: sets the trace output options.
Notes: can be combined by delimiting values with a comma
Values:
None: Do not write any elements.
LogicalOperationStack: Write the logical operation stack, which is represented by the return value of the CorrelationManager.LogicalOperationStack property.
DateTime: Write the date and time.
Timestamp: Write the timestamp, which is represented by the return value of the GetTimestamp method.
ProcessId: Write the process identity, which is represented by the return value of the Process.Id property.
ThreadId: Write the thread identity, which is represented by the return value of the Thread.ManagedThreadId property for the current thread.
Callstack: Write the call stack, which is represented by the return value of the Environment.StackTrace property.
-->
<add name="MediaPulseDemonListener"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener,
Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"
location="Custom"
customlocation="C:\stage\xenetdemon\log"
logfilecreationschedule="Weekly"
traceOutputOptions="None"
>
<!--Filter values
Off: Does not allow any events through.
Critical: Allows only Critical events through.
Error: Allows Critical and Error events through.
Warning: Allows Critical, Error, and Warning events through.
Information: Allows Critical, Error, Warning, and Information events through.
Verbose: Allows Critical, Error, Warning, Information, and Verbose events through.
ActivityTracing: Allows the Stop, Start, Suspend, Transfer, and Resume events through.
All: Allows all events through.
-->
<filter type="System.Diagnostics.EventTypeFilter"
initializeData="Information" />
</add>
<remove name="Default" />
</listeners>
</source>
</sources>
<switches>
<add name="Everything" value="All" />
</switches>
</system.diagnostics>