views:

436

answers:

2

I have 2 console apps projects in the same directory but different projects. There is some common code in the App_Code directory and a common app.config which gets build into seperate .exe.config files.

One module (VScanDemonStarter) starts up and writes to one logger with its own appender going to a seperate file. It uses an process.start() to execute the other module (VScanDemon) in another command prompt hidden window.

When I run VScanDemon by itself it puts entries into its log file. When I run VScanDemonStarter it puts entries into its (different) log file, the VScanDemon log file gets created, but no entries. I can see it is executing because some files get moved from one directory to another. Just no Log entries.

the config looks like

<root>
  <level value="INFO" />
</root>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >
  <param name="File" value="log/vscandemonstarter.log" />
  <param name="AppendToFile" value="true" />
  <rollingStyle value="Size" />
  <maxSizeRollBackups value="10" />
  <maximumFileSize value="10MB" />
  <staticLogFileName value="true" />
  <layout type="log4net.Layout.PatternLayout">
    <param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd hh:mm:ss} - %m%n" />
  </layout>
</appender>
<appender name="vsdemonlogfileappender" type="log4net.Appender.RollingFileAppender" >
  <param name="File" value="log/vscandemon.log" />
  <param name="AppendToFile" value="true" />
  <rollingStyle value="Size" />
  <maxSizeRollBackups value="10" />
  <maximumFileSize value="10MB" />
  <staticLogFileName value="true" />
  <layout type="log4net.Layout.PatternLayout">
    <param name="ConversionPattern" value="%-5p %d{yyyy-MM-dd hh:mm:ss} - %m%n" />
  </layout>
</appender>

and the code bodies set up and call the bodies with.

VScanDemonStarter:

top of module:

Private ReadOnly log As ILog = log4net.LogManager.GetLogger("default")

top of main:

    log4net.Config.XmlConfigurator.Configure()

example calls:

    If log.IsInfoEnabled Then log.Info("VScanDemonStarter:Main: ----called----")

VBScanDemon:

top of module:

Private ReadOnly log As ILog = log4net.LogManager.GetLogger("VSDemonLogger")

top of main:

    log4net.Config.XmlConfigurator.Configure()

VBScanDemon:

    If log.IsInfoEnabled Then log.Info("VScanDemon:Main: ----called----")

I don't get any log entries from VScanDemon. Anybody with ideas about the cause or fix.

Thanks,

---John Putnam

A: 

Are you useing the same log4net configuration for both modules? If not, are they really different at runtime?

I think "default" should return the Root-logger and "VSDemonLogger" the other one but that one is not included in your posted configuration.

EDIT: AFAIK all logger in the configuration will be "created", which results in the generated log files for your VSDemonLogger and VScanDemonStarter even if you do not use them.

You are using relativ pathes in the configuration, are they still valid for VSDemonLogger if you call it from VScanDemonStarter?

caahab
A: 

Sorry left out the top of the configuration

<log4net debug="true">
<logger name="default">
<level value="INFO"/>
<appender-ref ref="LogFileAppender" />
</logger>
<logger name="VSDemonLogger">
<level value="INFO"/>
<appender-ref ref="vsdemonlogfileappender" />
</logger>

I have one app.config but two projects in the same directory using it. They generate seperate configs from that one source .exe.config

I looked at the console output from VScanDemon and it looks like it is picking up the configuration with no issues. But still an empty log. I don't know if I need to add a flush or something.

Thanks,

---John Putnam

John Putnam