views:

486

answers:

2

I have a c++ application which logs to some file using log4cxx (RollingFile appender). I want to log into the same file, at the same time, from another module written in c#; so i configured log4net to use the same file, but i can't get the new messages in. If i deactivate the c++ logging, i can see c# messages. So i think it is a locking issue, and looked for a configuration option to tell log4cxx not to lock the file. I came into MinimalLock model for log4net, but couldn't find anything in log4cxx... does anybody know if it could be done, and how?

thanks in advance,

Ernesto Cullen

+3  A: 

I think that you might run into concurrency and contention problems no matter what configuration you use as long as you are attempting to have two different processes log to the same file.

You should look into sending log events from both processes to a third, centralized location - take a look at RemotingAppender in log4net, I assume log4cxx has something similar.

matt b
+1  A: 

Even if the question is quite old (and marked as answered) and you're probably already finished with your project:

log4net and log4cxx are distinct logging framworks that don't know of each other so you can't configure them to write to the same file. Only one of the framworks will have the file open for writing, whichever was first.

What I have done in a similar situation (a legacy c++ application with custom logging an a new c# module using log4net) is create a custom log4net appender that forwards traces into the old logging framework. In the project where I was involved the old C++ code had a Windows COM Interface for writing log messages which the custom appender used.

Another way would be using C++/CLI to create the custom appender.

froh42