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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:29:31+00:00 2026-06-11T20:29:31+00:00

I have an application that needs to write logs of two different types: application

  • 0

I have an application that needs to write logs of two different types: application log and audit log. Application log is used for debug purpose whereas audit log is to record the operations performed. Both logs will be in different files and each file should have only those logs as mentioned (means audit log file cannot have application log and vice versa).

How this can be implemented using log4j?
I know one way to implement this is by defining custom log level in log4j. Is there any other/better way to do?

  • 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-11T20:29:32+00:00Added an answer on June 11, 2026 at 8:29 pm

    I have had the same use case. In your log4j.xml you can define two different loggers and an appender for each one. An example therefore:

    <logger name="LOGGER_1" additivity="false">
        <appender-ref ref="LOGGER_FILE_1"/>
    </logger>
    
    <appender name="LOGGER_FILE_1" class="org.jboss.logging.appender.RollingFileAppender">
       <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
       <param name="File" value="${jboss.server.log.dir}/loggerFile1.log"/>
       <param name="Append" value="true"/>
       <param name="MaxFileSize" value="20MB"/>
          <param name="MaxBackupIndex" value="5"/>
    
          <layout class="org.apache.log4j.PatternLayout">
             <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
          </layout>
    </appender>
    

    In your Java-Code you can create a Logger with “Logger.getLogger(“LOGGER_1″)” which will write the log-outputs to the defined file.

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

Sidebar

Related Questions

If you have a Windows application that needs to write working files as part
I have an application in java that uses two different threads.And for sharing data
I have an application that needs to allow users to write expressions similar to
I have a console application project in C# 2.0 that needs to write something
Problem I have a UDPlistener application that I need to write a unit test
I have a need to write a GTK application in C that does some
I have an application that needs to copy, remove, modify, etc. files in the
I have an application that needs updating constantly. I would like to create a
I have an application that needs to work with a vendor-supplied API to do
I have an application that needs to check a website feed every second. Sometimes

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.