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 8363269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:08:11+00:00 2026-06-09T12:08:11+00:00

I am trying to localize the messages in a java application. I am using

  • 0

I am trying to localize the messages in a java application. I am using ResourceBundle loading based on Locale.

I want the messages on console to be localized and messages in log files to be in English.

What I am doing is this:

 if (bundle != null) { 
     MessageFormat formatter = new MessageFormat(bundle.getString(message));
     Object [] messageArgument = new Object[] {"arg1"};
     logger.info(formatter.format(messageArgument)); 
  } 

I have set the ConsoleHandler threshold to INFO.
The issue is, now even the info log file will contain localized message along with the console.

Is there a way to put English messages to log file and localized messages to console?

  • 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-06-09T12:08:13+00:00Added an answer on June 9, 2026 at 12:08 pm

    Edit: complete rewrite

    Normally when logging a string is passed to the logger which is already localized and cannot be translated after this. However the type for the message in log4j is actual Object and only later within the framework it is converted to an actual string. This is done by log4j before the message is passed on to the appenders but it looks like the appender can still get at the original object. So it would seem to be possible to write custom appenders for log4j in combination with a custom message type that would give the behaviour you want but it will be complex.

    I think you will be better of putting a layer on top of the console and log4j and just let that handle sending a localized message to the console directly and sending an english message to log4j.

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

Sidebar

Related Questions

Greetings all, I'm trying to localize a .NET/C# project. I'm using string resource files
I have been working on mvc3 application and trying to localize the same. I
I want to create a Producer that makes it possible to inject a java.util.ResourceBundle
I am trying to parse XML messages which are send to my C# application
Trying to localize text in ASP.NET labels... want to add a ':' after the
I'm trying to localize error messages from NHibernate.Validator. From what I have read, the
I'm trying to localize client side Javascript in a ASP .NET MVC application. The
I am trying to localize an existing cakephp application. For the most part I
I'm trying to find the easiest way to localize my app. I'm using sqlite,
I'm trying to develop localized help files. It works great with western languages but

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.