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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:07:17+00:00 2026-05-29T08:07:17+00:00

I want to maintain two Log Files in my web-application using apache Log4j.jar: 1)

  • 0

I want to maintain two Log Files in my web-application using apache Log4j.jar:

1) One log will contain all the Log messages of every level
2) Second log file will contain the Log messages of specific class

This is the configuration XML that I am using: (Not much aware of the tags used in the XML, was just trying out)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

<appender name="FILE1" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="D:/CSVExportLogs/CSVExportLogFile-ERROR.log"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c (%F:%L) - %m%n"/>
</layout>
</appender>

<appender name="FILE" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="D:/CSVExportLogs/CSVExportLogFile-INFO.log"/>
<param name="DatePattern" value="'.'yyyy-MM-dd"/>
<param name="Append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c (%F:%L) - %m%n"/>
</layout>
</appender>


<category name="com.taxware.mgmt.CustomerManager" additivity="false">
<priority value="warn"/>
<appender-ref ref="FILE"/>
</category>

<root>
<priority value="info"/>
<appender-ref ref="FILE1"/>
</root>
</log4j:configuration>

By the above xml I am getting only info messages in the FILE1, I want messages of all levels as well as the message of warn level that are going in the separate file in this file. Is there any solution available for 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-05-29T08:07:18+00:00Added an answer on May 29, 2026 at 8:07 am
    # Create ROOT logger(main logger) with level INFO, and add to it 2 appenders:
    # FILE_INFO, FILE_WARN. This means that all loggers by default will writes messages
    # in this 2 file appenders, with level INFO or higher
    log4j.rootLogger=INFO, FILE_INFO, FILE_WARN
    
    ######## LEVELS:
    # Set logging level to WARN for all classes and subclasses in package 
    # com.taxware.mgmt.CustomerManager
    log4j.category.com.taxware.mgmt.CustomerManager=WARN
    
    ######## APPENDERS:
    
    # FILE_INFO
    # Type of appender
    log4j.appender.FILE_INFO=org.apache.log4j.RollingFileAppender
    # File where to save all messages
    log4j.appender.FILE_INFO.File=D:/CSVExportLogs/CSVExportLogFile-INFO.log
    # Max file size, after that will be created new log file, and old file will be renamed
    log4j.appender.FILE_INFO.MaxFileSize=100KB
    # Maximum amount of old log files.
    log4j.appender.FILE_INFO.MaxBackupIndex=100
    # Patter of messages.
    log4j.appender.FILE_INFO.layout=org.apache.log4j.PatternLayout
    log4j.appender.FILE_INFO.layout.ConversionPattern=%d{ISO8601} [%-5p][%-24.24t][%32.32c] - %m%n
    # Custom level for appender. In this file will be add only messages with level INFO or highter
    log4j.appender.FILE_INFO.Threshold=INFO
    
    # FILE_WARN file appender
    log4j.appender.FILE_WARN=org.apache.log4j.RollingFileAppender
    log4j.appender.FILE_WARN.File=D:/CSVExportLogs/CSVExportLogFile-WARN.log
    log4j.appender.FILE_WARN.MaxFileSize=50KB
    log4j.appender.FILE_WARN.MaxBackupIndex=10
    log4j.appender.FILE_WARN.layout=org.apache.log4j.PatternLayout
    log4j.appender.FILE_WARN.layout.ConversionPattern=%d{ISO8601} [%-5p][%-24.24t][%32.32c] - %m%n
    # Custom level for appender. In this file will be add only messages with level WARN or highter
    log4j.appender.FILE_WARN.Threshold=WARN
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two files, CUSTOMER_ACCOUNT_LOG.TXT, CUSOMER_ID_LOG.TXT. Am this is log, maintain the timestamp and
I want to maintain state in my Perl web app. How can I do
I need to convert between these two classes, and want to maintain DRY but
I am currently building an Android app where I will have to maintain two
I want to maintain the Scroll Position between two pages. I have a Page
I'm working on a internal web application (only employees can log in) and need
I am using PHP and Mysql for developing an application. we have two copies
We want to maintain 3 webservices for the different steps of deployment, but how
I have a page in which I want to maintain the value of object
I want my window to always maintain a certain ratio of let's say 1.33333333.

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.