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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:00:48+00:00 2026-06-06T21:00:48+00:00

i am using log4j as my logging library, and i want the generated log

  • 0

i am using log4j as my logging library, and i want the generated log file to be inside my web application, so following are the jars i am using:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.4</version>
    </dependency>


    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.4</version>
    </dependency>

and following are log4j configuration:

log4j.rootLogger=DEBUG, stdout, R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=mylog.log

log4j.appender.R.MaxFileSize=10000KB

log4j.appender.R.MaxBackupIndex=3

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

# Control/Limit integrated frameworks logging messages
log4j.logger.org.springframework=ERROR

Problem: when i use file system path like log4j.appender.R.File=${user.home}/mylog.log
the file is created successfully with no problems, but when trying to use a relative path like: log4j.appender.R.File=mylog.log the file is not created.

please advise how to fix that.

  • 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-06T21:00:50+00:00Added an answer on June 6, 2026 at 9:00 pm

    Since you mentioned a web application the current working directory would be the web container root -like TOMCAT_HOME. So the log file path will be relative to your web container and not your web-application.

    Also most web-containers restrict writing files into the web application directories. There might be some configurations to do that – not sure.

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

Sidebar

Related Questions

I have a web application that dumps logging information in a file using log4j
I am using the Apache commons logging library and log4j to generate my log
We are using Log4j in our project for logging. I want to log some
In my application iam using Log4j for logging.Presently I am placing log4j.xml in WEB-INF/classes.
I have a medium-size Java Web-application using Log4J as logging-framework. Right now i am
In my web application I am using apache logging log4j. When I was working
I'm working on a project and we want to handle our logging using log4j.
I'm using Apache Commons Logging and SLF4J with log4j, but I also want to
My Application is using logging in two manner....1) programatic 2) log4j.xml I have to
I'm using log4j for my logging purposes and all my log files in .log

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.