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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:54:57+00:00 2026-06-09T03:54:57+00:00

I am trying to configure log4j for the first time but its not creating

  • 0

I am trying to configure log4j for the first time but its not creating myTest.log file. Below is my log4j.properties file and location of this file is WEB-INF/classes folder.

log4j.rootLogger=INFO, stdout, com.myTest

#tomcat logger
#log4j.logger.org.apache.catalina=DEBUG

log4j.logger.com.myTest=INFO

log4j.logger.org.apache.commons.configuration.PropertiesConfiguration=DEBUG

#appenders
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%5p] %d{yyyy-MM-dd HH:mm:ss} %m%n

log4j.appender.com.myTest=org.apache.log4j.FileAppender 
log4j.appender.com.myTest.File=myTest.log 
log4j.appender.com.myTest.MaxFileSize=15MB 
log4j.appender.com.myTest.MaxBackupIndex=10 
log4j.appender.com.myTest.layout=org.apache.log4j.PatternLayout 
log4j.appender.com.myTest.layout.ConversionPattern=[%5p] %d{yyyy-MM-dd HH:mm:ss} %m%n

log4j.appender.org.apache.ibatis=org.apache.log4j.FileAppender 
log4j.appender.org.apache.ibatis.File=myTest.log 
log4j.appender.org.apache.ibatis.MaxFileSize=15MB 
log4j.appender.org.apache.ibatis.MaxBackupIndex=10 
log4j.appender.org.apache.ibatis.layout=org.apache.log4j.PatternLayout 
log4j.appender.org.apache.ibatis.layout.ConversionPattern=[%5p] %d{yyyy-MM-dd HH:mm:ss}     %m%n

My controller class is like

@Controller
public class LoginController
{
static final Logger logger = Logger.getLogger(LoginController.class);

@RequestMapping("/login")
public ModelAndView login(){

    logger.debug("Test logs");
    logger.error("test error");

    return new ModelAndView("login"); 

}

 }

But I can’t see any myTest.log file in my Apache/log folder. Is this a place it should be?

Jar file I am using is log4j-1.2.16.jar. Is anything else required.

I am using Ubuntu and its first time I am using this.

  • 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-09T03:54:59+00:00Added an answer on June 9, 2026 at 3:54 am

    Put log4j.properties file in build/classes/ folder.

    Put file path to ${catalina.home}/logs/myTest.log.

      log4j.appender.com.myTest.File=${catalina.home}/log/myTest.log 
    

    Path of logs can be checked by writing below code in your LoginController class

        Enumeration e = Logger.getRootLogger().getAllAppenders();
        while ( e.hasMoreElements() ){
          Appender app = (Appender)e.nextElement();
         if ( app instanceof FileAppender ){
        System.out.println("File: " + ((FileAppender)app).getFile());
      }
    

    }

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

Sidebar

Related Questions

I'm not trying to configure log4j for an Eclipse project but for the IDE
I'm trying to configure logging for my web application (WAR), in log4j.properties : log4j.rootCategory=WARN,
I'm trying to configure log4j to use the SMTPAppender but I keep getting relay
I am trying to deploy the sample-app war file that comes with PushSDK.But was
I am trying to create 2 log files using log4j using this configuration: log4j.rootLogger=debug,stdout,logfile
I've been trying to configure the new Facebook Javascript API with my website, but
I'm trying to configure Team Foundation Reporting but without any success. The App Tier
I am trying to configure a network connection using ConfigurationManager.ProcessConfiguration, with the configuration file
I am trying to configure MySQL to be used with PHP and Apache. But
We're trying to configure our first server and we would like to have maven3

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.