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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:15:23+00:00 2026-06-11T10:15:23+00:00

We are creating one instance of logger by using private static Logger = Logger.getClass(ClassName.class);

  • 0

We are creating one instance of logger by using

private static Logger = Logger.getClass("ClassName.class");

Each action class has a logger. This worked fine in our test environment. However, it is giving occasional thread hungs in WAS 7 in Production environment. As per IBM server analysts, the log file is getting locked while waiting for a DB update.

Following is what I have in log4j.xml.

   <appender name="logger1" class="org.apache.log4j.DailyRollingFileAppender">
            <param name="File" value="/logs1/logFile.log" />
            <param name="DatePattern" value="'.'yyyy-MM-dd" />
            <param name="Threshold" value="DEBUG" />
            <param name="Append" value="true" />
            <layout class="org.apache.log4j.PatternLayout">
                <param name="ConversionPattern" value="%d [%t] %-5p (%F:%L) - %m%n" />
            </layout>
    </appender>

Could someone help ? Is there any advantage if I remove static ? Is there any advantage if I use SL4j LoggerFactory to get logger ?

EDIT : Relevant Point : The log4j.xml is shared between 2 applications. The applications are 2 WAR files within 1 EAR file. The log4j.xml has 2 appenders. Each application removes the other appender within the code.

  • 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-11T10:15:24+00:00Added an answer on June 11, 2026 at 10:15 am

    Is there any advantage if I remove static ?

    No. Logger.getClass would still return the same instance. Therefore this doesn’t change anything with respect to locking in log4j.

    Is there any advantage if I use SL4j LoggerFactory to get logger ?

    No (at least not for the problem you are facing). Locking is done in log4j. SLF4J is just a facade that would still delegate to log4j (unless you replace log4j by something else).

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

Sidebar

Related Questions

I have one instance of Class A. It has two members, Object A and
Create an instance from another one of different kind/class. Quick example: you are using
I am creating one form in html using table. Which have one Drop down
I am creating one application in which i am using jsp/servlet.. I want to
I am creating one sample project in android. i am using sample rss feed.
I am getting this error: The ObjectContext instance has been disposed and can no
I'm creating a game that uses cards. I have an AppController class with one
I have an activity that has 12 buttons, and each one plays a separate
am creating one application for student. I need to show digital clock with remaining
I am creating one asp page. In that page i defined one property like

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.