mixing log4cxx and log4net
Asked Answered
T

2

7

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

Teets answered 21/10, 2008 at 12:21 Comment(0)
U
4

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.

Unpaidfor answered 21/10, 2008 at 12:38 Comment(0)
G
1

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.

Graphomotor answered 16/2, 2009 at 22:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.