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

  • Home
  • SEARCH
  • 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 570061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:21:40+00:00 2026-05-13T13:21:40+00:00

I have a C++ application and a Java application that need to log messages

  • 0

I have a C++ application and a Java application that need to log messages in the same way. My Java application uses Apache Commons Logging, backed by a Log4j configuration. I need a single log4j configuration so I can change my logging preferences in one location. In my C++ application, I have captured all calls to printf() and fprintf(std***) and am thinking I have the following options:

  1. Fork in my C++ app, create a pipe from (f)printf() calls to the new processes stdin, and start a Java program that reads from stdin and logs using Commons Logging

  2. Create a JVM in the C++ app using JNI’s JNI_CreateJVM() and invoke a Java logging method when the (f)printf() calls are made

  3. Use something like Log4cxx to read the same configuration as the Java app and log natively in C++

I’d like to avoid option 3 as much as possible because I don’t want to add another third-party dependency to my applications. I understand there is a performance cost to crossing from C++ to Java, but I’m not sure if it will matter that much.

  • 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-13T13:21:41+00:00Added an answer on May 13, 2026 at 1:21 pm

    In addition to the performance cost, anything except option 3 is also horribly complicated (*).
    Also, I am not sure that there is a Java library that reads an InputStream and transforms it into Commons Logging calls. Even if there is, in order to be able to control filtering completely with the Java-side configuration, you would need to log everything at trace level into stdout (because the C++ code does not know about the configured log levels), which also sounds excessive .

    Go with Log4cxx, or make some C++ code that can read the configuration file yourself.

    (*) Okay, option 4 (have a wrapper script that redirects stderr/stdout from your unmodified C++ program to a Java program that translates the output into log entries) would not be very complex.

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

Sidebar

Ask A Question

Stats

  • Questions 311k
  • Answers 311k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Set the width and height HTML attributes of the canvas.… May 13, 2026 at 10:18 pm
  • Editorial Team
    Editorial Team added an answer Dancrumb was correct, for mutually exclusive options you use OptionGroup.… May 13, 2026 at 10:18 pm
  • Editorial Team
    Editorial Team added an answer I don't think that there is a way to add… May 13, 2026 at 10:18 pm

Related Questions

I have a Java application that uses a C++ DLL via JNI. A few
I have a third party .NET Assembly and a large Java application. I need
I have inherited a Java application (servlets) that runs under Tomcat. For historical reasons,
We have a C++ application on Windows that starts a java process. These two
I have written a standalone Java application that I've packaged into a jar file

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.