Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8940683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:06:05+00:00 2026-06-15T11:06:05+00:00

I am using Enterprise Library 5.0 in my win-form Application. 1. Regarding creating instances

  • 0

I am using Enterprise Library 5.0 in my win-form Application.

1. Regarding creating instances of Enterprise Library objects

What is the best way to Resolve the reference for Logging / exception objects? In our application, we have different applications in solution. So Solutions have below project:

CommonLib (Class Lib)
CustomerApp (winform app)
CustWinService (win service proj)
ClassLib2 (class Lib)

I have implemented logging / exceptions as below in CommonLib project. Created a class AppLog as below:

 public class AppLog
    {
        public static LogWriter defaultWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
public static ExceptionManager exManager = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();
        public AppLog()
        {
        }

    public static void WriteLog(string LogMessage, string LogCategories)
    {
        // Create a LogEntry and populate the individual properties.
            if (defaultWriter.IsLoggingEnabled())
            {
                string[] Logcat = LogCategories.Split(",".ToCharArray());
                LogEntry entry2 = new LogEntry();
                entry2.Categories = Logcat;
                entry2.EventId = 9007;
                entry2.Message = LogMessage;
                entry2.Priority = 9;
                entry2.Title = "Logging Block Examples";
                defaultWriter.Write(entry2);
            }
    }
}

And then I used Applog class as below for logging and exception in different projects:

            try
            {
                AppLog.WriteLog("This is Production Log Entry.", "ExceCategory");
                string strtest = string.Empty;
                strtest = strtest.Substring(1);
            }
            catch (Exception ex)
            {

                bool rethrow = AppLog.exManager.HandleException(ex, "ExcePolicy");

            }

So its the correct way to use Logging and Exception? or any other way i can improve it?

2. Logging File Name dynamic

In logging block, we have fileName which need to be set in app.config file. Is there a way I can assign fileName value dynamically through coding? Since I don’t want to hard code it in config file and paths are different for production and development environment.

Thanks
TShah

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:06:07+00:00Added an answer on June 15, 2026 at 11:06 am

    To keep your application loosely coupled and easier to test, I would recommend defining separate logging and exception handling interfaces, then having your AppLog class implement both. Your application can then perform logging and exception handling via those interfaces, with AppLog providing the implementation.

    You can have a different file name set per environment using config transforms, which I believe you can use in a winforms application by using Slow Cheetah.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Enterprise Library 4.x for my exception handling logging (ASP.NET application). Here
I am creating a console application using Enterprise Library my code is something like
I'm using the Enterprise Library Logging application block to allow my application to log
I'm using Enterprise Library 3.1 for logging exceptions for some web application. All exceptions
I'm using Enterprise Library 4.1 and I've configured the Logging Application Block to log
I am using the patterns & practices enterprise library (p&p EntLib) logging block to
We're using Enterprise Library 4.1 for logging (and exception handling/cryptography). Does anyone know a
I'm using enterprise library for logging web page events. Because page is load balanced
I am using Enterprise Library 4.0 and I can't find any documentation on creating
I am logging messages using Enterprise Library. I want some of these (typically errors

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.