# LOGGING

AyaNova keeps a log of important events for troubleshooting purposes.

AyaNova logs to the file log-ayanova.txt.

Every Wednesday it archives the current log file to a numbered archive log file, for example log-ayanova-1.txt, log-ayanova-2.txt etc.
Any log older than 4 weeks is deleted permanently; 4 total logs are kept, which means a total of one month of logs are kept at any given time.

## INFORMATION SECURITY AND PRIVACY

By design and policy no personally identifiable information is intentionally gathered into log files.

User logins are logged in an anonymized way:

* AyaNova anonymizes IP addresses by masking the final segment of the address
* Passwords are not logged
* Users are logged as their internal id number not their name

Sometimes 3rd party tools may log to the log file and we may need to restrict them to conform to our privacy policy. If you find any personally identifiable information in a log file please advise us immediately at [support@ayanova.com](mailto:support@ayanova.com).

## Log path

By default AyaNova logs to a "logs" folder situated below the folder where AyaNova is started.
You can override this and set a custom log location by command line argument or by setting the "AYANOVA_LOG_PATH" environment variable.

Example command line log path parameter

`"dotnet run --AYANOVA_LOG_PATH=/home/gztw/Documents/temp/cmdlinelogs"`

If both a command line parameter and an environment variable are set the command line parameter takes precedence.

## Log level

AyaNova supports 6 levels of logging, the default level is "Info" which is a medium level and will log general operations and any errors or warnings that may arise.

**WARNING**
AyaNova server will run ***extremely slowly*** when setting a log level lower than Info.  A very large amount of information is logged at Debug or lower levels and each item logged takes time away from the normal server operations.  Unless directed to by technical support or attempting to diagnose a specific problem, you should avoid setting a log level lower than "Info".

You can set the log level via environment variable or command line parameter "AYANOVA_LOG_LEVEL".

For example from the command line

`"dotnet run --AYANOVA_LOG_LEVEL=Info"`

Below are listed the accepted values for log level from highest to lowest.  A level logs everything at that level and above.
So, for example, "Trace" level will log the most and "Fatal" will log the least.

* `Fatal` - Critical errors that prevent AyaNova from running or force it to shut down.  This setting results in the least amount of logging.
* `Error` - Logs all of the above plus errors that AyaNova can recover from and continue to operate.
* `Warn` -  Logs all of the above plus issues that AyaNova can work around but should be looked into and are warnings to system operators.
* `Info` -  Default level. Logs all the above levels plus normal behavior in low level of detail.  Basic general operations are logged like startup and shutdown, configuration changes etc.
* `Debug` - Logs all the above plus every request to the server in detail and information about internal operations.
* `Trace` - Logs all the above plus highest level detail of internal program code operations. Useful primarily to AyaNova technical support to troubleshoot a specific issue, but too detailed for normal purposes.

## Troubleshooting logging

If you are having issues with logging you can enable a logger diagnostic log with a command line parameter or environment variable.
Enabling this setting will cause a log file named "log-ayanova-logger.txt" to be written to the folder AyaNova is started in.

Command line parameter

`-- AYANOVA_LOG_ENABLE_LOGGER_DIAGNOSTIC_LOG=true`

or set the environment variable

`AYANOVA_LOG_ENABLE_LOGGER_DIAGNOSTIC_LOG = true`

Warning: this diagnostic log should be disabled as soon as it's not required.  Unlike the normal log, this log file is not automatically trimmed so it will grow in size forever.
