Logging in Enterprise Library

Topics: Enterprise Library Core, Logging Application Block
Apr 15, 2011 at 5:04 AM


   I am creating some sample applicaiton for Enterprise Logging and i am new to this topic, when i click "Button" i have following proplem("The configuration section for Logging cannot be found in the configuration source."), i created Web.config file also(Add New Items->General-> Selecte Application Configuration File->Changes App1.config as Web.config) in my projecte, eventhough i am gettting this problem.Can you correct my problem, here i attached my sample code. Let me know, if you have any doubt, I feel this is a correct forum to discuss this issue, if am wrong please tell me, where i need to post



<Window x:Class="LoggingEvent1.MainWindow"
  Title="MainWindow" Height="350" Width="525">
  <Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="120,76,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" />

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.ObjectBuilder2;

namespace LoggingEvent1
 /// <summary>
 /// Interaction logic for MainWindow.xaml
 /// </summary>
 public partial class MainWindow : Window
  public MainWindow()

  private void button1_Click(object sender, RoutedEventArgs e)
   LogEntry logEntry = new LogEntry();
   logEntry.EventId = 100;
   logEntry.Priority = 2;
   logEntry.Message = "Informational message";
   logEntry.Categories.Add("UI Events");   



Apr 15, 2011 at 5:37 AM

This is my Web.Config file.


<?xml version="1.0" encoding="utf-8" ?>
Apr 15, 2011 at 6:07 AM

Is this a wpf application?  If yes, your config file should be named as app.config. 


Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.

Apr 15, 2011 at 9:13 AM

Yes, this is Wpf Application

Apr 15, 2011 at 9:38 AM

Renaming your config file to app.config should fix the problem.  This is the name of the config file which the CLR searches for and at runtime, creates a copy of it in the project's output folder with the filename {applicationName}.exe.config


Sarah Urmeneta
Global Technologies and Solutions
Avanade, Inc.

Apr 16, 2011 at 5:37 PM


   I got output to this problem, thanks for your quick reply