# Application Logging

An administrator can configure how Exago handles logging in order to change or extend functionality.

# Logging Defaults

By default Exago saves a log file `WebReportsLog.txt` to the application’s Temp path (specified in the base configuration). The logger maintains a lock on the file for the lifespan of the application. The log file cannot be edited or deleted without restarting the application or releasing the lock.

> Note: As of version 2018.1, the .NET API logs to the file [`Temp]\WebReportsApiLog.txt`

There are five configurable verbosity levels for the logger. By default, Exago logs at the Info level.

Use the following administrative setting to set the log level or disable logging:

( Other Settings ) Write Log File

- None – Turns logging off.
- Error – Logs application errors.
- Warn – Logs application warnings, which may be indicative of problems in the configuration, as well as all Error messages.
- Info – Logs SQL statements, number of rows returned from each statement, and report execution information, as well as all Warn and Error messages. Report execution information includes the following:

  ### Execution start

  Start time, userId, companyId, full report name, filter summary.

  ### Execution end

  End time, runtime, userId, companyId, full report name.

- Debug – Logs a variety of debugging information that can be used to time specific parts of the application, as well as all Info, Warn, and Error messages.

# log4net

The logger can load its configuration from a file and continually watch the file for changes. A config file can be used to lock or unlock the log file, change the log file name and path, as well as customize and extend logging capability.

> Note: A custom log configuration file will override the application's configuration settings.

To use a custom log configuration, create a file called `log4net.config` in the Config directory of the Exago web application. The following shows a sample config file:

    <?xml version="1.0" encoding="UTF-8"?>
    <log4net>
      <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
        <file value="C:\Exago\Temp\WebReportsLog.txt" />
        <encoding value="utf-8" />
        <appendToFile value="true" />
        <rollingStyle value="Size" />
        <maxSizeRollBackups value="10" />
        <maximumFileSize value="1MB" />
        <staticLogFileName value="true" />
        <lockingModel type="log4net.Appender.FileAppender+ExclusiveLock" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%date %-5level [%property{SessionId}] %message%newline" />
        </layout>
      </appender>
      <!-- Setup the root category, add the appenders and set the default level -->
      <root>
        <level value="INFO" />
        <appender-ref ref="RollingFileAppender" />
      </root>
    </log4net>

For more information and extensibility, see: Apache log4net. See the following examples for some simple modifications:

### Change Logfile Location

    <file value="Path\To\Log.txt" />

Specifies the directory and filename for the log file.

### Change Logging Level

    <level value="INFO" />

Specifies the Exago logging level: ERROR, INFO, or DEBUG.

### Unlock the Log File

    <lockingModel type="log4net.Appender.FileAppender+ExclusiveLock" />

Configures the locking model in use for the log file. To temporarily disable the write lock, you can use: log4net.Appender.FileAppender+MinimalLock

> Note: This will result in a performance reduction until it is reset.

### Changing the Pattern

    <conversionPattern value="%date %-5level [%property{SessionId}] %message%newline" />

Configures which information is logged and the format of how it is written.

See Apache log4Net SDK Documentation - PatternLayout Class for details on how to format the `conversionPattern`.