views:

46

answers:

2

I am building an application that calls upon a compiled executable. Said executable's source code project file is referenced by the solution file for the parent application. The child executable is a stand alone command line application. The parent is a effectively a GUI wrapper to the console application. When I compile the console application, I have access to all of log4net's functionality that has been built into the application. However, when I compile the parent project that references the console application's source code files, everything runs correctly but no logs are generated. What would cause this error to occur, and how can this occurrence be fixed? log4net's internal debugging mechanism doesn't throw any messages.

A: 

You need to configure logging (appenders, etc.) for both applications. Did you configure log4net for the wrapper?

Assaf Lavie
A: 

For log4net to start logging within the referenced assembly you will have to:

  • Call the Configure() function of log4net by either calling log4net.Config.XmlConfigurator.Configure() when your application starts, or by adding [assembly: log4net.Config.XmlConfigurator(Watch=true)] to the AssemblyInfo.cs file of your wrapper application.
  • Create an log4net configuration section in the app.config for your GUI wrapper if you haven't already done so. Add an app.config file to your project, and copy your log4net configuration information from the referenced library into it.
  • Ensure that the account running the application has access to write and create files within the log directory (assuming your using file-based logging).

For more info about setting up your config see: http://logging.apache.org/log4net/release/manual/configuration.html

Joe
The GUI already has properly implemented log4net up and running. Both use the assemblyinfo.cs decoration method.
XBigTK13X
If that's the case, then log4net configuration should be occurring. Does the GUI application have an application configuration file, set up with the log4net configuration section? Finally, is the issue with the GUI application logging happen all the time or sporadically?
Joe
Each application has a separate app.config file that is setup to use log4net. This issue occurs continuously, there has never been a point when logging was functional within the console application when called by the GUI. Whatever project is set as the Startup project is the only one that has access to logging support, although everything else within the application functions as desired.
XBigTK13X
Thanks. Could you post the log4net section of your application config file for the GUI application? If i'm reading your response correctly, you're saying that other areas of the GUI application do have logging support, and just the portion regarding the console application being called by the gui is not logging. Is that accurate?
Joe
Anything within the GUI that calls the logger works fine. The GUI works through the Process() command calling a standalone console application. The console app's source code is set as a project dependency for the GUI. The calls to the logger made by the console application are what get left out from within the GUI.
XBigTK13X
So, in the output folder of the GUI application (e.g. bin\Debug), you should have a .exe for your GUI process a .exe.config for your GUI process, a .exe for your console process, and a .exe.config for your console process. Since it sounds like you're invoking the console app as a separate process, I believe you would need to have both .config files in your build output since the console app would still rely on it's own config file. Can you confirm that both config files are there?
Joe
The console application's .config file is not present in the output directory. The GUI's .config file is there. However, app.config within the console application is set to "Copy always."
XBigTK13X
To solve the issue I renamed each application's app.config to <applicationname>.exe.config. This does in fact resolve the issue, but is there a better solution to the problem?
XBigTK13X