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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:50:51+00:00 2026-05-26T20:50:51+00:00

Im using websphere server and JSF 2.0 In my managed bean i have declared

  • 0

Im using websphere server and JSF 2.0

In my managed bean i have declared the following:

private final static Logger LOGGER = Logger.getLogger(ABC.class .getName());

The following code is in the constructor of the bean.

try {
FileHandler handler = new FileHandler("logging.txt");
LOGGER.addHandler(handler);
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
String stacktrace = sw.toString();
LOGGER.log(Level.SEVERE, stacktrace);
} catch (Exception logException) {
System.err.println("Logging error");
}

The code is writing all the logs to the console but not to the file. The log file logging.txt is also not getting created.

Should I create the file by myself or the path is wrong. Help me

  • 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-26T20:50:51+00:00Added an answer on May 26, 2026 at 8:50 pm

    From your code:

    FileHandler handler = new FileHandler("logging.txt");
    

    That will create a logging.txt file in the appserver’s default working directory. You can determine the exact path to the default working directory as follows:

    System.out.println(new File(".").getAbsolutePath());
    

    The logging.txt file should be in that folder.

    However, this isn’t the best idea. Using relative paths is a bad idea when you cannot control the default working directory from inside your application. You should use absolute paths instead. I.e., start with /:

    FileHandler handler = new FileHandler("/path/to/logging.txt");
    

    In Windows, this will be saved in the same disk as where the current working directory is. Otherwise, when you want to change disks as well, you would also need to prefix with C: or something.

    Note that this problem is in no way related to JSF. You would have exactly the same problem with any other Java API/framework.

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

Sidebar

Related Questions

I am using Websphere application server 7.0.0.0.9 with ;OpenJPA 1.2.3-SNAPSHOT'. I have Set property
We're using Spring/Hibernate on a Websphere Application Server for AIX. On my Windows machine,
We're using Spring 2.5.4/Hibernate 3.2/Websphere Application Server 6.1.0.17. We've deployed the application on an
I have seen this question about deploying to WebSphere using the WAS ant tasks.
I am using Eclipse 3.2.2 with WebSphere Portlet Factory Designer 6.0.2. I have a
I am using IBM Websphere Application Server v6 and Java 1.4 and am trying
I'm using Oracle Advanced Queues via JMS from within Websphere App Server. Does anyone
i have developed an application using jsf 1.2. it worked fine with apache tomcat
I am using Websphere Application Server to create a typical web application where UI
Hi I am using IBM Websphere application Server 7.0 trial version and the priod

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.