Logging to a text file

You can have any ADAM application log to a text file by simply changing your application's configuration file and adding the TextFileLogListener to the /Adam.Tools/logListeners-element. For example:

XML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="Adam.Tools" 
             type="Adam.Tools.ConfigurationHandler, Adam.Tools" />
  </configSections>
  <Adam.Tools>
    <logListeners>
       <add type="Adam.Tools.LogHandler.ConsoleLogListener,Adam.Tools" 
            severity="verbose" />
       <add type="Adam.Tools.LogHandler.TextFileLogListener,Adam.Tools" 
            severity="Normal" 
            path="C:\log.txt"/>
    </logListeners>
  </Adam.Tools>
</configuration>

This configuration file ensures that every log entry created by ADAM or any log entry that you made yourself in your custom application by calling the App.Log-methods or the LogManager.Write-methods is logged to C:\log.txt as well as to the console.

While we're talking about log listeners. Did you know that the only difference between the Application.Log instance methods and the LogManager.Write static methods is that Application.Log first logs to the database currently logged on to and then calls LogManager.Write? LogManager.Write is the method that logs to all the log listeners specified in the application's configuration file.

Comments

Leave a comment
You must be logged in to post comments.
Sign in now
 
 
CATEGORIES
AnnouncementsDocMaker StudioEngineSharePoint ConnectorWeb DevelopmentWebinarsWorkflow Studio
rss feed