An add-in that writes to a log
This simple add-in demonstrates the use of the XLL+ logging framework.
If the add-in is opened, the Logging/DoSomething menu is used, and Excel is then closed, something like the following will be written to the log file:
Sat Apr 11 00:13:48 5344 INFO CLogDemoApp OnXllOpenEx() for C:\logdemo\debug\LogDemo.xll Sat Apr 11 00:13:51 5344 FATAL Global Something very bad happened Sat Apr 11 00:13:51 5344 ERROR Global Something quite bad happened Sat Apr 11 00:13:51 5344 WARN Global Something unexpected occurred Sat Apr 11 00:13:51 5344 INFO Global aNumber=0xff Sat Apr 11 00:13:51 5344 DEBUG Global aNumber (in decimal)=255 Sat Apr 11 00:13:52 5344 INFO CLogDemoApp OnXllClose() for C:\logdemo\debug\LogDemo.xll
The log file,
LogDemo.log can be found in the user's temporary directory.
You can view it on the command line by entering the following:
The log is also written, in a shorter format, to the Output window of Visual Studio,
You can control the level of logging by changing the
statements in the log configuration file
Note that the configuration file is copied to the output directory
alongside the XLL file itself, as part of the project's build process.
The sample demonstrates the following tasks:
OnXllOpenEx()by calling XllConfigurator::configure().
The following steps were significant in creating and completing the LogDemo application.
CLogDemoApp. This logger was used in some member functions of
Some of the events and all of add-in functions in the application contain logging macros at various levels. Change the settings in LogDemo.xll.log.ini to include and exclude various log items.
Each sample project is located in a sub-directory of the Samples directory of the XLL+ installation. To use the sample project, open the solution file LogDemo.sln or the project file LogDemo.vcproj.
You can enable debugging under Excel by using the Setup Debugging command in the XLL+ ToolWindow.
When delivered, the help files are excluded from the build.
You can enable the help build by selecting the files
in the Solution Explorer,
and using the right-click menu to view Properties.
Select the page "Configuration Properties/General" and
set the "Excluded from build" property to "No".
See Generating help
in the User Guide for more information.