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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:00:38+00:00 2026-06-17T08:00:38+00:00

I want to to do like this: <appender name=ErrorLog class=org.apache.log4j.FileAppender> <param name=File value=${error.log.path}/> <param

  • 0

I want to to do like this:

<appender name="ErrorLog" class="org.apache.log4j.FileAppender">
        <param name="File" value="${error.log.path}"/>
        <param name="Append" value="true" />
        <param name="Threshold" value="ERROR"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%C{1} %L [%t] %d{dd MMM,yyyy HH:mm:ss.SSS} %-5p - %m%n" />
        </layout>
    </appender>

Notice this line: <param name="File" value="${error.log.path}"/>

I tried to set the values like this:

public static void main(String[] args) {
     System.setProperty("error.log.path", "/test/crm/log/error.log");
     ApplicationContext context = new ClassPathXmlApplicationContext("blah.xml");
     ..........
     .......... 
  }

But I don’t see any effect.

Is log4j gets configured before calling the main method?

Is there any other way to do 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-17T08:00:39+00:00Added an answer on June 17, 2026 at 8:00 am

    Look at this thread

    It looks like you did everything right. I don’t think there is any difference between setting the property inside your main class with System.setProperty() and specifying it via the command line as long as it happens befor actual log4j initialization.

    I think your issue is that your logging framework gets loaded before you specify the property.
    I can say that the logging framework (log4j) will get configured when you call the configurator. Stuff like BasicConfigurator.configure() (in your case its xml configurator).

    Otherwise the first attempt to use the logging will cause message like “log4j is not configured properly”.

    The real question is whether your code snippet with ‘main’ is not oversimplified.

    With this in mind, another question that I have to ask – whether you’re running inside some container or you’re running a real vanilla method main and configure everything by yourself? I’m asking because if you’re running in container, the chances are that container will by itself somehow configure its logging, for example JBoss will do so. In this case more investigation is required.

    Hope this helps

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

Sidebar

Related Questions

I have this appender in my logback.xml <appender name=FILE class=ch.qos.logback.core.rolling.RollingFileAppender> <File>logFile.log</File> <rollingPolicy class=ch.qos.logback.core.rolling.TimeBasedRollingPolicy> <FileNamePattern>logFile.%d{yyyy-MM-dd}.log</FileNamePattern>
I want to change the path and file name of my log4j logfile dynamically.
I would like to set the log file name for a log4j and log4net
I want some like this: How make it ideologically correct?
I want something like this: abcdab.search(/a/g) //return [0,4] Is it possible?
I want a method like this: public async void DoSomething() { DoSomethingElse(); } But
I want a setup like this: +- /ApplicationFolder -- App.exe -- Core.dll -- AnotherShared.dll
I want to do like this : http://ajaxload.info/ here is my code: <!DOCTYPE html>
In C I want a function like this: bool RemoveFirstIndex(char* inArray[]) which goes in
I have code that I want to look like this: List<Type> Os; ... foreach

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.