# Logging with Designer

Designer uses the NLog logging engine (the configuration file, nlog.config, is stored in the Designer install path), which provides multiple levels of logs for the application. The logs are saved in C:\Users\User_Name\Documents\Cognex Designer\Logs, with the default file names being CD_Log_Current.csv, CD_Log0.csv, CD_Log1.csv, CD_Log2.csv, ..., CD_Log9.csv (the logs are saved from newest to oldest). Renaming or deleting a log will cause a new log to be generated.

Designer uses a rolling archive, so there will never be more than 11 log files (the maximum disk space used for logging is approximately 800MB).

The logging levels, from highest to lowest in verbosity, are: Trace, Debug, Info (the default), Warn, Error and Fatal.

- Trace: Every little piece of information that may be useful, e.g. Log entering and exiting a method, with a lock inside of it.
- Debug: Information that can be used to debug an application, e.g. when a button is clicked.
- Info: Useful information about how the system is operating, e.g. if a Device is connected/disconnected.
- Warn: When an exception or something else occurs that prevents normal use of the application; even though the application anticipated it, and handled it gracefully.
- Error: When an exception or something else occurs that prevents normal use of the application; the application stops the routine when it occurs.
- Fatal: Either on a "caught" crash, or something that causes the application to unexpectedly shutdown.

The logging level can be changed by modifying the NLog.config file (located at C:\Program Files\Cognex\Designer\{DesignerVersion#}\NLog.config), or by adding <space>/LogLevelFile={LogLevel} to the Designer Launcher shortcut (e.g. "C:\Program Files\Cognex\Designer\2.5\Cognex.Designer.Launcher.exe" /LogLevelFile=Trace).

You can also use the $System.Log.Write("message") and $System.Log.WriteException("message", exception) methods to post Info level log messages to the Output window of Designer, or the log file of your runtime environment in a deployed application.