Configuring Logging for Alchemy Compatibility Packages

Save to PDF

Applies to: Alchemy

03/03/2023 Cliff Hobbs   ID: 1821485

As detailed in Logging in Alchemy Compatibility Packages, Cloudhouse Alchemy Compatibility Packages include a logging component based on log4net to aid troubleshooting.

Logging in a Compatibility Package can be changed in the following ways:

Changing the Log directory

By default, a Compatibility Package's Deployment, Run, and Usage executables log to text files within the current working directory.

However, you can configure a Compatibility Package to log to a relative or absolute directory or a directory, based on environment variables.

Process to change the log directory for a Compatibility Package

  1. Navigate to the Compatibility Package's folder.
  2. Open the relevant config file in a text editor for the type of log file you want to change: 
    • Cloudhouse.Container.Deployment.exe.config for the Deployment log
    • Cloudhouse.Container.Run.exe.config for the Run log 
    • Cloudhouse.Container.Usage.exe.config for the Usage Log.
  3. Locate the <file> element and prepend the directory's path to the name of the file specified for the attribute value.
  4. Save any files you change.

The next time you deploy or run the Compatibility Package, it will use the newly configured values. 

Examples

See the following examples for worked examples.

Changing the Fully Qualified File Path

To write to c:\temp\cloudhouse\RunWorkflowLog.txt, change the value to:

<file value="C:\\temp\\Cloudhouse/RunWorkflowLog.txt" />

Changing the Relative Path

To write to a log directory relative to the current directory (for example ..\Logs\Package), change the value to:

<file value="..\\Logs\\Package/RunWorkflowLog.txt" />

 Using Environment Variables

To write to the user's local app data use ${APPDATA} or another environment variable:

<file value="${PROGRAMDATA}\Cloudhouse\RunWorkflowLog.txt" />

>Configuring Logging to the Windows Event Log

Configuring Logging to the Windows Event Log

By default, Compatibility Packages log to text files in their current working directory. However, Compatibility Packages can be configured to log to the Windows Event Log instead.

Process to Configure a Compatibility Package to Log to the Windows Event Log

  1. Open the relevant config file in a text editor for the type of log file you want to change:
    • Cloudhouse.Container.Deployment.exe.config for the Deployment log
    • Cloudhouse.Container.Run.exe.config for the Run log 
    • Cloudhouse.Container.Usage.exe.config for the Usage Log.
  2. Use the sample replacement code below.
  3. Change Cloudhouse AppName to the desired application name.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
 <configSections>
  <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
 </configSections>
 <startup> 
   <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
 </startup>
 <log4net>
   <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
     <logName value="Application"/>
     <applicationName value="Cloudhouse AppName"/>
     <layout type="log4net.Layout.PatternLayout">
       <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
     </layout>
   </appender>

 <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender"> 
   <layout type="log4net.Layout.PatternLayout">
     <conversionPattern value="%date %-5level %logger - %message%newline"/>
   </layout>
 
 </appender>
   <root>
    <level value="INFO"/>
    <appender-ref ref="ConsoleAppender"/>
    <appender-ref ref="EventLogAppender"/>
   </root>
 </log4net>
</configuration>

Note

Text in red italics indicates changes to the default configuration.

Configuring DEBUG Logging

By default, Compatibility Packages log INFO messages when they are deployed or run.

However, they can be configured to log INFO, WARNING, ERROR, DEBUG messages if required.

Process to Configure a Compatibility Package to Log DEBUG messages

  1. Open the Source Compatibility Package, not the version that has been deployed.
  2. Open the relevant configuration file:
    • Cloudhouse.container.deployment.exe.config for deployment logging, stored in the same folder the Compatibility Package is being deployed from.
    • Cloudhouse.container.run.exe.config for run logging, stored in the same folder the Compatibility Package is being deployed from.
  3. Locate the following section inside the relevant config file:
<level value="INFO" />
      <appender-ref ref="ConsoleAppender" />
      <appender-ref ref="RollingFileAppender" />
    </root>
  1. Change INFO to the required level, for example for DEBUG the entry would be:
<level value="DEBUG" />
       <appender-ref ref="ConsoleAppender" />
       <appender-ref ref="RollingFileAppender" />
    </root>
  1. Save the file.
  2. Redeploy/Run the Compatibility Package.
Source:
Was this article helpful?

Table of Contents

    Can't find what you're looking for?

    Contact Support