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 7541545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:55:18+00:00 2026-05-30T07:55:18+00:00

I am using log4net in a try with expression and it is not working.

  • 0

I am using log4net in a try with expression and it is not working. I think something is missing but I don’t know what.
Here is my code :

let clusterIDArray = try
                         myfunction
                     with
                         log.Fatal("my function is not working")   


log.Debug("my function is working")

Any ideas?

  • 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-05-30T07:55:20+00:00Added an answer on May 30, 2026 at 7:55 am

    There are two mistakes in your code snippet:

    • You didn’t execute your function. I suppose that you did execute it in your real code; it’s the matter of making up an example.
    • You didn’t catch exceptions or your try...with... block is not syntactically correct.

    Assuming that we catch exceptions and return an array in any case, a more idiomatic way of logging could be:

    let clusterIDArray =
        try
           let result = myfunction args // Assume args are arguments declared before
           log.Debug("my function is working")
           result
        with 
        | ex ->
           // ex is of type exception which can be parsed by log4net
           log.Fatal("my function is not working: ", ex)   
           [||]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Log4Net 2.0, I have it working as required but which to add
I'm using log4net to log in my app. My FileAppender is working fine, but
Backstory: I'm using log4net to handle all logging for a project I'm working on.
I'm thinking about using log4net in a MOSS(SharePoint) 2007 project, but I need to
I've got a simple winform test app i'm using to try some Log4Net Dependency
I try to inject log4net in a ILogger property of my service class but
I'm transforming xml using the following code. It works fine for one xslt but
I'm just starting using the Log4Net library and having problems configuring it. I don't
Am using Log4Net in my code,it start throwing this weird exception when my process
I have just begun working on a C# application (using log4net). I'm supposed to

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.