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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:18:09+00:00 2026-05-15T17:18:09+00:00

I have a web app which upon startup stores the server local timezone in

  • 0

I have a web app which upon startup stores the server local timezone in a global static member and then sets the DefaultTimeZone of JVM to GMT.

During startup log4j is logging messages in server default timezone.

Now when i change my log level in log4j.properties the log level is changed dynamically and now the log4j logs messages in GMT time .

My requirement is to log messages always in server local time zone.

How can i achieve this in my scenario? any pointers will be really appreciated.

Thank you

  • 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-15T17:18:10+00:00Added an answer on May 15, 2026 at 5:18 pm

    Now when i change my log level in log4j.properties the log level is changed dynamically

    This implies that you’ve configured log4j to watch your configuration file for changes, a configuration which is not recommended for webapps (see also this related SO question).

    What is occuring is something like this

    1. Your app starts up, log4j is initialized, TimeZone.getDefault() returns the machine’s timezone
    2. You change the default Timezone JVM-wide
    3. You make a change to the log4j config, the log4j watcher thread notices the change, re-initializes the logger hierarchy, sees the new default Timezone

    I’d suggest a few options here:

    • Don’t use configureAndWatch in a servlet environment
    • Don’t change the default TimeZone JVM-wide, as this can impact lots of unrelated components (such as log4j, as you’ve seen). Instead, if you have code that has a requirement to output dates in GMT, make sure all of the code goes through the same code path to obtain the default zone you want to use, for example make sure all of your time-related code calls something like TimeZone getMyAppDefaultTimeZone().

    Changing JVM-wide defaults for something only your application code needs can have much larger unintended consequences.

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

Sidebar

Related Questions

Have an ASP.net web app which works fine for a few days, but then
I have a web app which connects to a server using a TCP connection
I have a web app which lets the user select the excel spreadsheet and
I have a Flash web app which displays user submitted PNG files. Files are
I have a Silverlight web app which uses ASP.net Website administration tool for user
The thing I have a web app (asp.net) which needs to have a feed.
I have a user profile page on my web app which has contact information.
I have a web app (.NET 3.5) which is sending notifications by email to
I have a app which will download a file from web. The download action
In my web app I have a line which looks like this: small textbox

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.