1

I am sure that this question is answered multiple times. But somehow, it's not working for me.

My appender is something like this.

<appender name="myAppender" class="org.apache.log4j.DailyRollingFileAppender">
    <param name="Threshold" value="DEBUG"/>
    <param name="File" value="D:\\out\\MyApp_${output}.log"/>
    <param name="DatePattern" value="'.'yyyy-MM-dd"/>
    <param name="Append" value="true"/>
    <layout class="org.apache.log4j.PatternLayout">
        <param name="ConversionPattern" value="%d{DATE} %5p %C{1}:%L - %m%n"/>
    </layout>
</appender>

I am setting the system property before creating the logger.

System.setProperty("output", "abc");

Then, I am creating the logger like this.

logger = Logger.getLogger("myAppender");

But the output file is generated only like this.

MyApp_.log

Am I missing something? Thanks in advance.

Shan
  • 21
  • 1
  • 6

1 Answers1

0

Did you try -Doutput=abc during the startup?

Here is another thread with similar problem that may help you.

How to give environmental variable path for file appender in configuration file in log4j

Community
  • 1
  • 1