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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:56:54+00:00 2026-06-14T21:56:54+00:00

I am trying log4j2 to create log file to the system I am developing

  • 0

I am trying log4j2 to create log file to the system I am developing right, I have followed the instruction on their site and there is no error occurred when I run it, but the log is not saved on where I set it (ex. “D:\logs\app.log”).

Here is My log4j.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration status="OFF">
  <appenders>
    <RollingFile name="MyRollingFile" fileName="D:/logs/app.log"
                 filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log.gz">
      <PatternLayout>
        <pattern>%d %p %C{1.} [%t] %m%n</pattern>
      </PatternLayout>
      <Policies>
        <TimeBasedTriggeringPolicy />
        <SizeBasedTriggeringPolicy size="250 MB"/>
      </Policies>
      <DefaultRolloverStrategy max="20"/>
    </RollingFile>
    <Console name="Console" target="SYSTEM_OUT">
      <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
    </Console>
  </appenders>
  <loggers>
    <logger name="Log_RollingFile" level="TRACE" additivity="false">
      <appender-ref ref="MyRollingFile"/>
    </logger>
    <root level="ERROR">
      <appender-ref ref="Console"/>
    </root>
  </loggers>
</configuration>

I tried to :

  • delete app.log to see if my configuration (D:\logs\app.log) works. When I run the application it creates app.log so I think it means that it sees the configuration and the only thing is it is NOT SAVING the log.info that I did in java application
  • Change root level to “TRACE”, and it prints the log.info.

[EDIT:]

I have also these libraries on my classpath

  • log4j-api-2.0-beta3.jar
  • log4j-core-2.0-beta3.jar

Am I missing something on RollingFile configuration or a library (maybe)?

Thanks in advance.

  • 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-14T21:56:55+00:00Added an answer on June 14, 2026 at 9:56 pm

    Your logger name is incorrect.

    As explained in the configuration instructions you linked to, the logger should be named according to the package/classes you wish to capture logging for.

    In their example the logger named com.foo.Bar would log everything from the Bar class in package com.foo with TRACE level.

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

Sidebar

Related Questions

I'm trying to use Maven to create an executable jar file that includes the
I am trying to do centralised logging of a distributed system using Log4J2 and
I am trying to create 2 log files using log4j using this configuration: log4j.rootLogger=debug,stdout,logfile
I'm trying to read a fixed width text file stored in Cassandra File System
I'm trying to write to the Windows Event Log and I have a nagging
I am trying to write a log parser for log4j. I have a regular
I'm trying to log into a html file using Log4j filappender. My properties file
Introduction: I'm trying to get additional fields to log with log4j, and its working
I am trying to run a jar with the log4j.xml file on the file
Trying to copy the msdn refernce here doesn't work and gives an error I

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.