Configuration Listeners
A Configuration Listener defines the information that will be tracked within the Logging Application Block, including defining the format name, the type of data being logged, the level of data included (Error, Warning, Information or Verbose messages) and the rollover behavior for any files based upon the Configuration Listener.
Configuration Listeners are defined within the <loggingConfiguration/> element, by the child element <listeners/> which, in turn, contains child elements, <add/>. The <add/> elements define each individual Configuration Listener as a part of the <loggingConfiguration/>
For example, in the default installation for a Task Service, the <listeners/> element contains 3 child elements <add listenerDataType ... />, <add source ... /> and <add fileName ... />. Each of these child elements provides details about what information is being logged, where to find the formatting for that information and how to control the output selected for that information. To continue the example, we define the output for a file as:
<
add fileName="Bluespring.TaskService.log" footer="" formatter="Bluespring.TaskService.Formatter" header="" rollFileExistsBehavior="Overwrite" rollInterval="Midnight" rollSizeKB="0" timeStampPattern="yyyy-MM-dd" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" traceOutputOptions="None" filter="All" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="Bluespring.TaskService.LogFile"/>
This Configuration Listener indicates information will be made available by the
Rolling Flat File Trace Listener for a File named: Bluespring.TaskService.log according to the format specified by: Bluespring.TaskServiceFormatter (see:
How the Logged Information is Formatted). This file will be rolled over at midnight (local time on the Server hosting the Task Service) with the rollover file named by a time stamp in yyyy-MM-dd format and will include all information that can be available through the Configuration Listener, which information can then be specified for its
output by referencing the Configuration Listener's name, Bluespring.TaskService.LogFile.
Updating the Configuration Listener controls the amount of information which can be made available and the file name and its rollover behavior (where applicable) or the name of the Event Log (where applicable).
For example, we can limit the amount of information in the log file to only errors by updating the filter attribute in the example above to: filter="Error". Similarly, we can control the information output to the Event Log: BsTaskService by updating the filter attribute for the <add source ... /> Configuration Listener.