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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:23:16+00:00 2026-05-26T01:23:16+00:00

I have log4net implemented in a Visual Studio 2010 VB.NET Windows service. It used

  • 0

I have log4net implemented in a Visual Studio 2010 VB.NET Windows service. It used to work, but not anymore.

I have a sub RunTasks that gets started by the service every minute.
When I debug this procedure using a console project in the same solution, the logging works. However when I install the service and run it, and debug it using VS by attaching to the process, I found out that IsInfoEnabled, IsDebugEnabled, IsErrorEnabled etc. are all set to false, and I guess that’s why the logging is not working, although RunTasks is executed by the service.

I have the following class, if I understand things right the XMLConfigurator is started before GetLogger.

Imports System.Reflection

<Assembly: log4net.Config.XMLConfigurator(ConfigFile:="LogConfig.xml", Watch:=True)> 

Public NotInheritable Class Logging

    Private Shared _LogName As String
    Private Shared _ilog As log4net.ILog

    Private Sub New()
    End Sub

    Public Shared ReadOnly Property ILog() As log4net.ILog
        Get
            If _ilog Is Nothing Then
                _ilog = log4net.LogManager.GetLogger(LogName)
            End If

            Return _ilog
        End Get
    End Property

    Private Shared ReadOnly Property LogName() As String
        Get
            If _LogName = "" Then

                'If GetType(MySettings).GetProperty("LogName") IsNot Nothing Then
                '    _LogName = GetType(MySettings).GetProperty("LogName").GetValue(MySettings.Default, Nothing)
                'End If
                If _LogName = "" Then _LogName = "DefaultLogger"
            End If

            Return _LogName
        End Get
    End Property

End Class

The logging itself looks like this:

ILog.Info("Starting RunTasks ... ")

And here is my LogConfig.xml

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <log4net>
    <appender name="textfileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="myLogFile.log" />
      <appendToFile value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="3" />
      <maximumFileSize value="100KB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date{yyyy-MM-dd HH:mm:ss} %-5level - %message%newline" />
      </layout>
    </appender>
    <logger name="DefaultLogger">
      <level value="ALL" />
      <appender-ref ref="textfileAppender" />
    </logger>
  </log4net>
</configuration>
  • 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-26T01:23:16+00:00Added an answer on May 26, 2026 at 1:23 am

    I found the answer myself, I had to move the following line of code:

    <Assembly: log4net.Config.XMLConfigurator(ConfigFile:="LogConfig.xml", Watch:=True)> 
    

    … (see first code block above) to the AssemblyInfo.vb of the solutions startup project. XMLConfigurator has to be executed before GetLogger is.

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

Sidebar

Related Questions

I have configured log4Net EventLogAppender for Asp.Net 2.0. However it does not log anything.
I have a problem with Log4Net. Running C# .Net 2.0 Log4Net Ver. Not Sure.
I have a C#.NET 4.0 app that uses log4net for logging. Under Windows XP,
I'm running Visual Studio 2008 - and have a problem with log4net logging (v1.2.10).
I only have experience with log4net however that does not mean that there are
I have been attempting to get log4net logging in my asp.net web application with
We have an application that logs using log4net. But we would like to delete
This is my situation. I have successfully implemented logging to remote syslog using log4net.
I have developed an asp.net web application containing 40-50 pages. I have implemented logger
I have log4net loggers configured to run with my unit tests, but for a

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.