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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:15:21+00:00 2026-05-23T17:15:21+00:00

This is a standalone java application. I am using the configuration file below and

  • 0

This is a standalone java application.

I am using the configuration file below and having two problems.

1) I’m getting logs to stdout and I don’t know why.

2) I’m getting ALL log messages in my error log even though I have tried to direct only error and higher to the error log.

I am using the BasicConfigurator without specifying an explicit path to the log4j.xml file. The xml file is in the same jar as my classes. It is creating and writing to the appropriate logs in addition to these problems so the configuration is being applied.

3) In addition, I have had no luck having the log4j.xml file outside of the jar so I can change it at runtime. How do I do that?

<!--appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
    <param name="Threshold" value="DEBUG"/>
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%-5p [%F:%L] - %m%n"/>
    </layout>
</appender-->

<!-- working dir is $CATALINA_TMPDIR. send logs to log dir. -->
<appender name="ROLL" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="/var/log/company/application.log"/>
    <param name="MaxFileSize" value="5MB"/>
    <param name="MaxBackupIndex" value="9"/>
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
    </layout>
</appender>

<appender name="ERRORLOG" class="org.apache.log4j.RollingFileAppender">
    <param name="File" value="/var/log/rocketvox/company/error.log"/>
    <param name="MaxFileSize" value="5MB"/>
    <param name="MaxBackupIndex" value="9"/>
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
    </layout>
</appender>

<category name="com.company">
    <priority value="ALL"/>
    <appender-ref ref="ROLL"/>
</category>

<category name="com.mattx">
    <priority value="ALL"/>
    <appender-ref ref="ROLL"/>
</category>

<root>
    <priority value="error"/>
    <appender-ref ref="ERRORLOG"/>
</root>

  • 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-23T17:15:22+00:00Added an answer on May 23, 2026 at 5:15 pm

    Add -Dlog4j.debug to the application’s JVM args to see exactly what log4j is doing and which configuration file it uses.

    Your problem is using BasicConfigurer – for configuring using a file named log4j.xml, you don’t need to use any explicit log4j Configurer in your application code, as the default log4j initialization logic will kick in to pick log4j.xml (or log4j.properties, if no xml is found) from the classpath.

    See Default Initialization Procedure from the log4j manual.

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

Sidebar

Related Questions

I have written a standalone Java application that I've packaged into a jar file
Hai I am developing a standalone application using Java in which I am using
I am using eclipse 3.5 Galileo enterprise edition for development of java standalone applications.I
I am having issues with properties file when I try to make my standalone
I am having problems with my java assignment. I have been working on it
I have implemented a standalone java application which uses the swing framework for GUI.As
I've created a stand alone java desktop application using Netbeans. I want a way
I have a XML file like this : <?xml version=1.0 encoding=UTF-8 standalone=no ?> <user>
I have a standalone enum type defined, something like this: package my.pkg.types; public enum
I want the last of these lines in a standalone application to pass with

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.